Skip to Content

SizedBox

A box with a fixed Width and/or Height. When used with a child, it constrains the child to those dimensions. When used without a child, it acts as a fixed-size empty space.

Properties

Height

The explicit height in logical pixels. Null means unconstrained on the vertical axis.

IsExpand

When true, the element grows to fill all available space on both axes (equivalent to flex-grow: 1). Width and Height are ignored when this is true.

Width

The explicit width in logical pixels. Null means unconstrained on the horizontal axis.

Methods

Expand

Creates an SizedBox that grows to fill all available space on both axes (equivalent to flex-grow: 1).

ParameterDescription
keyAn optional key for reconciliation identity.

FromSize

Creates an SizedBox with explicit width and/or height.

ParameterDescription
widthWidth in logical pixels. Null means unconstrained.
heightHeight in logical pixels. Null means unconstrained.
keyAn optional key for reconciliation identity.

GetChildren

ShouldRebuild

Returns the child element when one was set, or an empty list when used as a dimensioned spacer without a child.

Square

Creates a square SizedBox with equal width and height.

ParameterDescription
sizeThe width and height in logical pixels.
keyAn optional key for reconciliation identity.
Last updated on