Skip to main content
The Stac Positioned widget controls where a child of a Stack is positioned. It corresponds to Flutter’s Positioned widget and allows precise positioning using coordinates and optional sizing constraints. Use it with JSON to declare positioned children inside a Stack. To learn more about the Positioned widget in Flutter, see the official documentation.

Positioning constraints

Only two of the three horizontal values (left, right, width) may be set; at least one must be omitted or null. Similarly, only two of the three vertical values (top, bottom, height) may be set; at least one must be omitted or null.

Properties

The Dart API also supports named constructors: StacPositioned.fill(), StacPositioned.fromRect(), StacPositioned.fromRelativeRect(), and StacPositioned.directional(). These are not available in JSON format.

Example

Dart-Only Constructors

The following named constructors are available in Dart but not in JSON:

StacPositioned.fill()

Creates a positioned widget with left, top, right, and bottom defaulting to 0.0, so the child fills the stack unless overridden.

StacPositioned.fromRect()

Creates a positioned widget from a StacRect, setting left, top, width, and height. right and bottom are set to null.

StacPositioned.fromRelativeRect()

Creates a positioned widget from relative edges: left, top, right, and bottom are required; width and height are null.

StacPositioned.directional()

Creates a positioned widget using start and end instead of left and right. The mapping depends on textDirection: for LTR, startleft and endright; for RTL, the opposite. Only two of start, end, and width may be set; only two of top, bottom, and height may be set.