setLayoutAxisLength method
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
void setLayoutAxisLength(LayoutAxis axis, double? value) {
// This is necessary because we cannot extend the accessor assignment of
// NullableVector2 to trigger some extra functionality
// (i.e. setting height/width) when the accessor is set.
//
// We also cannot use listeners at the moment, because listeners are
// triggered when either height/width are set, when we need things to happen
// *only* when height or width are set. Current functionality results in
// a race condition.
switch (axis) {
case LayoutAxis.x:
_layoutSizeX = value;
width = _layoutSizeX ?? intrinsicSize.x;
case LayoutAxis.y:
_layoutSizeY = value;
height = _layoutSizeY ?? intrinsicSize.y;
}
}