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).
| Parameter | Description |
|---|---|
key | An optional key for reconciliation identity. |
FromSize
Creates an SizedBox with explicit width and/or height.
| Parameter | Description |
|---|---|
width | Width in logical pixels. Null means unconstrained. |
height | Height in logical pixels. Null means unconstrained. |
key | An 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.
| Parameter | Description |
|---|---|
size | The width and height in logical pixels. |
key | An optional key for reconciliation identity. |