setLayoutAxisLength method

  1. @override
void setLayoutAxisLength(
  1. LayoutAxis axis,
  2. double? value
)
override

Sets the appropriate layout dimension based on axis. This is needed because currently there's no other way, at the LayoutComponent level, to selectively set width or height without setting both. e.g. to set Y axis to 100, setLayoutAxisLength(LayoutAxis.y, 100)

If you intend to set both axes at the same time, use setLayoutSize

This is not equivalent to calling setLayoutSize with one of the axes set to null. Doing so would actually set the axis to the intrinsic length of that dimension.

Implementation

@override
void setLayoutAxisLength(LayoutAxis axis, double? value) {
  super.setLayoutAxisLength(axis, value);
  final child = this.child;
  if (inflateChild && child != null && value != null) {
    // We want to set the child's size.
    if (child is LayoutComponent) {
      child.setLayoutAxisLength(axis, value);
    } else {
      child.size[axis.axisIndex] = value;
    }
  }
}