Skip to Content
API ReferenceContainer

Container

A general-purpose container element that combines decoration, sizing, and padding in a single node. Maps to a UIToolkit VisualElement with decoration, size constraints, and padding applied directly to its style. When used without a child, it renders as a styled box with no content.

Constructor

Container

Creates an Container element.

ParameterDescription
decorationOptional visual decoration.
widthOptional explicit width in logical pixels.
heightOptional explicit height in logical pixels.
paddingOptional inner padding.
centerChildWhen true, centers the child along both axes.
onTapOptional tap callback registered directly on the native element.
keyAn optional key for reconciliation identity.

Properties

CenterChild

When true, the container centers its child along both axes using flex alignment. Equivalent to wrapping the child in a Center but applied directly on this element’s native node.

Decoration

The visual decoration applied to this container (background color, border, corner radius, shadow). Null means no decoration.

Height

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

OnTap

Optional tap callback. When set, the container’s native element registers a pointer-down handler that invokes this action. Use this instead of wrapping in a GestureDetector when the tap handler must not introduce an extra layout node.

Padding

Inner padding applied between the container boundary and its child. Null means no padding.

Width

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

Methods

GetChildren

ShouldRebuild

Returns the child element when one was set, or an empty list when used as a styled box without content.

Last updated on