computeSpacing method
double
computeSpacing({
- required ParentLayout parent,
- required LayoutAxis axis,
- required double viewportSize,
override
Computes the actual spacing value.
Spacing units are computed during layout to determine margins, padding, or gaps between elements. The calculation considers the parent layout context, the axis direction, and the available viewport size.
Parameters:
parent: The parent layout providing contextaxis: The axis along which spacing is calculated (LayoutAxis.horizontal or LayoutAxis.vertical)viewportSize: The size of the viewport along the specified axis
Returns the computed spacing value in pixels.
Implementation
@override
double computeSpacing({
required ParentLayout parent,
required LayoutAxis axis,
required double viewportSize,
}) {
ChildLayout? otherChild = parent.findChildByKey(key!);
if (otherChild == null) {
return 0.0;
}
return switch (axis) {
LayoutAxis.horizontal => otherChild.size.width,
LayoutAxis.vertical => otherChild.size.height,
};
}