AbsoluteItem.builder constructor
- 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 builder(
- BuildContext context,
- 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;