AbsoluteItem.builder constructor

const AbsoluteItem.builder({
  1. Key? key,
  2. int? paintOrder,
  3. SizeUnit? width,
  4. SizeUnit? height,
  5. SizeUnit? minWidth,
  6. SizeUnit? maxWidth,
  7. SizeUnit? minHeight,
  8. SizeUnit? maxHeight,
  9. PositionUnit? top,
  10. PositionUnit? left,
  11. PositionUnit? bottom,
  12. PositionUnit? right,
  13. double? aspectRatio,
  14. required Widget builder(
    1. BuildContext context,
    2. LayoutBox box
    ),
})

Creates an absolutely positioned item with a builder function.

The builder parameter is required and provides a function that constructs the child widget dynamically. The builder receives the BuildContext and a LayoutBox containing layout information.

The top, left, bottom, right parameters specify the position offsets from the parent's edges. You can use any combination of these to position the item. If both top and bottom are specified, the height is determined by the difference. The same applies to left and right for width.

The width and height parameters specify the explicit size of the item. If null, the size is determined by content or positioning constraints.

The minWidth, maxWidth, minHeight, maxHeight parameters set size constraints for the item.

The aspectRatio parameter maintains the width/height ratio if specified.

The paintOrder parameter controls the painting order when items overlap. Lower values are painted first (behind), higher values are painted last (on top).

Example

AbsoluteItem.builder(
  top: PositionUnit.fixed(20),
  left: PositionUnit.fixed(30),
  width: SizeUnit.fixed(100),
  height: SizeUnit.fixed(50),
  builder: (context, layoutBox) {
    return Container(
      color: Colors.red,
      child: Text('Position: ${layoutBox.offset}'),
    );
  },
)

Implementation

const factory AbsoluteItem.builder({
  Key? key,
  int? paintOrder,
  SizeUnit? width,
  SizeUnit? height,
  SizeUnit? minWidth,
  SizeUnit? maxWidth,
  SizeUnit? minHeight,
  SizeUnit? maxHeight,
  PositionUnit? top,
  PositionUnit? left,
  PositionUnit? bottom,
  PositionUnit? right,
  double? aspectRatio,
  required Widget Function(BuildContext context, LayoutBox box) builder,
}) = BuilderAbsoluteItem;