layout method

  1. @override
void layout(
  1. Rectangle<int> componentBounds,
  2. Rectangle<int> drawAreaBounds
)
override

Layout this component.

Implementation

@override
void layout(Rectangle<int> componentBounds, Rectangle<int> drawAreaBounds) {
  _componentBounds = componentBounds;
  _drawAreaBounds = drawAreaBounds;

  // Update the output range if it is different than the current one.
  // This is necessary because during the measure cycle, the output range is
  // set between zero and the max range available. On layout, the output range
  // needs to be updated to account of the offset of the axis view.

  final outputStart =
      isVertical ? componentBounds.bottom : componentBounds.left;
  final outputEnd = isVertical ? componentBounds.top : componentBounds.right;

  final outputRange = reverseOutputRange
      ? ScaleOutputExtent(outputEnd, outputStart)
      : ScaleOutputExtent(outputStart, outputEnd);

  final scale = this.scale!;
  if (scale.range != outputRange) {
    scale.range = outputRange;
  }

  _updateProvidedTicks();
  _updateProvidedTickWidth(_componentBounds!.width, _componentBounds!.height);
  // Update animated ticks in layout, because updateTicks are called during
  // measure and we don't want to update the animation at that time.
  _updateAxisTicks();
}