Skip to content

SizedBox

A widget that imposes specific dimensions on its child.

Learn more: Layout

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

SizedBox(
width: 20,
height: 3,
child: Text('fixed area'),
)

A null width or height adds no constraint on that axis beyond the bounds supplied by the parent, so the child chooses its size there. With no child, a null axis resolves to the parent’s minimum (often zero).

ParameterTypeDefaultDescription
width:int?—Requested width in cells, or null to add no width constraint.
height:int?—Requested height in rows, or null to add no height constraint.
child:Widget?—Content constrained to the requested size, or null for an empty box.

Convenience for a fixed width x height box with no child.

ParameterTypeDefaultDescription
cols:intrequiredFixed width in terminal cells.
rows:intrequiredFixed height in terminal rows.

Convenience for a zero-sized leaf.

This constructor has no public parameters.

Forces the box to fill the parent’s bounded space on both axes. An unbounded axis remains unconstrained, and the child chooses its size. In a Row or Column, use Expanded or Flexible to claim remaining main-axis space; inflexible children are unbounded on that axis.

ParameterTypeDefaultDescription
child:Widget?—Content forced to fill all bounded space supplied by the parent.

Forces the box to be dimension x dimension. Equivalent to SizedBox(width: dimension, height: dimension, child: child).

ParameterTypeDefaultDescription
dimension:int?—Width and height in cells, or null to defer both axes to the parent.
child:Widget?—Content constrained to the square.

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

Category: Layout · All widgets