Skip to content

Stack

Overlays children at the same origin and lets later siblings overwrite earlier ones.

See also: IndexedStack to show one child at a time.

Learn more: Layout

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

Stack(
children: [
const Editor(),
Positioned(left: 2, top: 0, child: Text('● saved')),
],
)

Non-positioned children determine the stack’s size (intrinsic of the largest non-positioned child) and are constrained per fit. Positioned children float on top with explicit offsets and (optional) sizes, and don’t affect the stack’s size. Children paint in declaration order, so a later child covers an earlier one wherever it draws. Where it covers half of a wide character (a CJK character or an emoji, say), that whole character is cleared rather than left half-drawn.

ParameterTypeDefaultDescription
fit:StackFitStackFit.looseHow non-positioned children are constrained. StackFit.passthrough passes the stack’s own constraints through unchanged, so a stack with one non-positioned child lays it out exactly as if the stack weren’t there — the shape of a popup layered over an app that must not move the app.
children:List<Widget>const []The widgets below this widget in the tree, in layout and paint order.

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

Category: Layout · All widgets