computeSize method

  1. @override
double computeSize({
  1. required ParentLayout parent,
  2. required ChildLayout child,
  3. required LayoutHandle<Layout> layoutHandle,
  4. required LayoutAxis axis,
  5. required LayoutSize contentSize,
  6. required LayoutSize viewportSize,
})
override

Computes the actual size value for this unit.

The calculation considers the parent layout context, child properties, layout axis, content size, and viewport constraints to determine the final size.

Parameters:

  • parent: The parent layout providing context and constraints
  • child: The child element being sized
  • layoutHandle: Handle for layout operations
  • axis: The axis along which sizing is calculated
  • contentSize: The natural size of the content
  • viewportSize: The available viewport size

Returns the computed size value.

Implementation

@override
double computeSize({
  required ParentLayout parent,
  required ChildLayout child,
  required LayoutHandle layoutHandle,
  required LayoutAxis axis,
  required LayoutSize contentSize,
  required LayoutSize viewportSize,
}) {
  double size = switch (axis) {
    LayoutAxis.horizontal => parent.viewportSize.width,
    LayoutAxis.vertical => parent.viewportSize.height,
  };
  return size * factor;
}