Skip to content

ConstrainedBox

Forces its child to satisfy additional layout constraints. Sits between SizedBox (which sets one fixed size) and a bare child (which uses whatever the parent gave it) — useful when you want “at least 20 cells wide, no more than 40” or similar bounds.

Learn more: Layout

Import: package:fleury/fleury.dart, or package:fleury/fleury_core.dart in browser code.

ConstrainedBox(
minWidth: 24,
maxWidth: 48,
child: Text('bounded content'),
)

The child is laid out within the intersection of the parent’s constraints and these additional ones. If the intersection is empty (e.g. you asked for minWidth: 50 inside a parent that offered at most 20), the parent’s bounds win.

ParameterTypeDefaultDescription
minWidth:int?—Additional minimum width in cells, bounded by the parent’s constraints.
maxWidth:int?—Additional maximum width in cells, bounded by the parent’s constraints.
minHeight:int?—Additional minimum height in rows, bounded by the parent’s constraints.
maxHeight:int?—Additional maximum height in rows, bounded by the parent’s constraints.
child:WidgetrequiredContent laid out within the intersection of these and parent constraints.

ConstrainedBox is defined in packages/fleury/lib/src/widgets/basic.dart.

Category: Layout · All widgets