Skip to Content
Mix 2.0 is in development! You can access the Mix 1.0 docs here.
DocsWidgetsStackBox

StackBox

StackBox is equivalent to Flutter’s Stack and Container widgets combined, but provides powerful styling capabilities through the Mix framework.

StackBox enables you to create stacked layouts with visual styles such as decoration, padding, margin, constraints, and box/stack behaviors—all customizable and responsive.

You can use the StackBoxStyler API to fluently compose your layout and decoration styles. Example:

final style = StackBoxStyler() .padding(EdgeInsets.all(16)) .decoration( BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(12), ), ) .alignment(Alignment.center); StackBox( children: [ Icon(Icons.star, size: 48), Positioned( right: 0, bottom: 0, child: Text('Badge'), ), ], style: style, )

Constructor

PropTypeRequired / Default Value
styleStyleconst StackBoxStyler.create()
styleSpecStyleSpec?Optional
childrenList<Widget>const <Widget>[]

Style API Reference

StackBox Methods

MethodDescription
animateSets animation
alignmentSets the alignment for the box.
transformAlignmentSets the transform alignment for the box.
clipBehaviorSets the clip behavior for the box.
modifierSets the widget modifier.
stackAlignmentSets the alignment for the Stack widget.
fitSets how the Stack widget sizes itself based on its children.
textDirectionSets the text direction for the Stack widget.
stackClipBehaviorSets the clip behavior for the Stack widget.
stackApplies a custom StackStyler to the StackBox.
foregroundDecorationForeground decoration instance method
paddingPadding instance method
marginMargin instance method
transformSets the transform for the box.
decorationDecoration instance method - delegates to box
constraintsConstraints instance method
wrapModifier instance method
variantsSets the variants list.
borderRadiusSets the border radius property via decoration.
borderBorder instance method

Border Radius

MethodDescription
borderRadiusAllSets border radius for all corners.
borderRadiusTopSets border radius for the top corners.
borderRadiusBottomSets border radius for the bottom corners.
borderRadiusLeftSets border radius for the left corners.
borderRadiusRightSets border radius for the right corners.
borderRadiusTopLeftSets border radius for the top left corner.
borderRadiusTopRightSets border radius for the top right corner.
borderRadiusBottomLeftSets border radius for the bottom left corner.
borderRadiusBottomRightSets border radius for the bottom right corner.
borderRadiusTopStartSets border radius for the top start corner (directional).
borderRadiusTopEndSets border radius for the top end corner (directional).
borderRadiusBottomStartSets border radius for the bottom start corner (directional).
borderRadiusBottomEndSets border radius for the bottom end corner (directional).
borderRoundedSets a uniform circular radius for all corners.
borderRoundedTopSets a circular radius for the top corners.
borderRoundedBottomSets a circular radius for the bottom corners.
borderRoundedLeftSets a circular radius for the left corners.
borderRoundedRightSets a circular radius for the right corners.
borderRoundedTopLeftSets a circular radius for the top left corner.
borderRoundedTopRightSets a circular radius for the top right corner.
borderRoundedBottomLeftSets a circular radius for the bottom left corner.
borderRoundedBottomRightSets a circular radius for the bottom right corner.
borderRoundedTopStartSets a circular radius for the top start corner (directional).
borderRoundedTopEndSets a circular radius for the top end corner (directional).
borderRoundedBottomStartSets a circular radius for the bottom start corner (directional).
borderRoundedBottomEndSets a circular radius for the bottom end corner (directional).

Border

MethodDescription
borderTopSets the top border.
borderBottomSets the bottom border.
borderLeftSets the left border.
borderRightSets the right border.
borderStartSets the start border (RTL-aware).
borderEndSets the end border (RTL-aware).
borderVerticalSets vertical borders (top & bottom).
borderHorizontalSets horizontal borders (left & right).
borderAllSets all borders.

Constraint

MethodDescription
widthSets both min and max width to create a fixed width
heightSets both min and max height to create a fixed height
minWidthSets minimum width constraint
maxWidthSets maximum width constraint
minHeightSets minimum height constraint
maxHeightSets maximum height constraint
sizeSets both width and height to specific values
constraintsOnlyCreates constraints with only specified values, supporting priority resolution

Decoration

MethodDescription
colorSets background color
gradientSets gradient with any GradientMix type
shadowSets single shadow
shadowsSets multiple shadows
elevationSets elevation shadow
imageSets image decoration
shapeSets box shape
shapeCircleSets a circular shape (CircleBorder)
shapeStadiumSets a stadium shape (StadiumBorder)
shapeRoundedRectangleSets a rounded rectangle shape (RoundedRectangleBorder)
shapeBeveledRectangleSets a beveled rectangle shape (BeveledRectangleBorder)
shapeContinuousRectangleSets a continuous rectangle shape (ContinuousRectangleBorder)
shapeStarSets a star shape (StarBorder)
shapeLinearSets a linear border shape (LinearBorder)
shapeSuperellipseSets a superellipse shape (RoundedSuperellipseBorder)
backgroundImageSets a background image from an ImageProvider
backgroundImageUrlSets a background image from a network URL
backgroundImageAssetSets a background image from an asset path
foregroundLinearGradientSets a foreground linear gradient
foregroundRadialGradientSets a foreground radial gradient
foregroundSweepGradientSets a foreground sweep gradient
linearGradientSets a background linear gradient
radialGradientSets a background radial gradient
sweepGradientSets a background sweep gradient

Shadow

MethodDescription
shadowOnlyCreates a single box shadow with named parameters
boxShadowsCreates multiple box shadows from a list of BoxShadowMix
boxElevationCreates box shadows from Material Design elevation level

Spacing

MethodDescription
paddingTopSets the top padding.
paddingBottomSets the bottom padding.
paddingLeftSets the left padding.
paddingRightSets the right padding.
paddingXSets horizontal (left and right) padding.
paddingYSets vertical (top and bottom) padding.
paddingAllSets padding on all sides.
paddingStartSets the start (leading) padding.
paddingEndSets the end (trailing) padding.
paddingOnlySets custom padding for each side with priority resolution.
marginTopSets the top margin.
marginBottomSets the bottom margin.
marginLeftSets the left margin.
marginRightSets the right margin.
marginXSets horizontal (left and right) margin.
marginYSets vertical (top and bottom) margin.
marginAllSets margin on all sides.
marginStartSets the start (leading) margin.
marginEndSets the end (trailing) margin.
marginOnlySets custom margin for each side with priority resolution.

Transform

MethodDescription
rotateSets rotation transform
scaleSets scale transform
translateSets translation transform
skewSets skew transform
transformResetResets transform to identity (no effect)

Variant

MethodDescription
variantAdds a single variant to this style.
onDarkCreates a variant for dark mode.
onNotCreates a variant for when the context does NOT match the provided variant.
onLightCreates a variant for light mode.
onBuilderCreates a variant using a builder function that receives the build context.
builderDeprecated: Use [onBuilder] instead.
onBreakpointCreates a variant based on the specified breakpoint.
onPortraitCreates a variant for portrait device orientation.
onLandscapeCreates a variant for landscape device orientation.
onMobileCreates a variant for mobile breakpoint.
onTabletCreates a variant for tablet breakpoint.
onDesktopCreates a variant for desktop breakpoint.
onLtrCreates a variant for left-to-right text direction.
onRtlCreates a variant for right-to-left text direction.
onIosCreates a variant for iOS platform.
onAndroidCreates a variant for Android platform.
onMacosCreates a variant for macOS platform.
onWindowsCreates a variant for Windows platform.
onLinuxCreates a variant for Linux platform.
onFuchsiaCreates a variant for Fuchsia platform.
onWebCreates a variant for web platform.

Widget State Variant

MethodDescription
onHoveredCreates a variant for hover state
onPressedCreates a variant for pressed state
onFocusedCreates a variant for focused state
onDisabledCreates a variant for disabled state
onEnabledCreates a variant for enabled state (opposite of disabled)