Widgets
Box is equivalent to Flutter's Container, it provides
styling capabilities through the Mix framework. It can be used to
create visually styled boxes with decoration, padding, margins, transforms,
and constraints.
You can use BoxStyler to create styles with a fluent API. Example:
final style = BoxStyler ()
. size ( 200 , 120 )
. color ( Colors .blue)
. borderRadius (. circular ( 12 ))
. padding (. all ( 16 ))
. shadow (
. color ( Colors .blue.shade200)
. blurRadius ( 12 )
. offset (x : 0 , y : 4 ),
);
final label = TextStyler ()
. color ( Colors .white)
. fontSize ( 18 )
. fontWeight (.w600);
Box (
style : style,
child : StyledText ( 'Hello Mix' , style : label),
)
The preview below shows this style applied.
Resolving preview metadata...
Prop Type Required / Default Value styleBoxStyler?Optional, defaults to const BoxStyler.create() styleSpecStyleSpec<BoxSpec>?Optional (resolved style spec) childWidget?Optional
Method Description clipBehaviorSets the clip behavior. alignmentSets the alignment. modifierSets the widget modifier. foregroundDecorationSets the foreground decoration. transformSets the transform and optionally the alignment. constraintsSets the box constraints. paddingSets the padding. marginSets the margin. decorationSets the decoration. animateSets the animation configuration. wrapWraps with a widget modifier. borderRadiusSets the border radius. borderSets the border decoration. variantsSets the style variants.
Method Description keyframeAnimationCreates a keyframe animation. It will animate through the given timeline. phaseAnimationCreates a phase animation. It will animate through the given phases.
Method Description 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).
Method Description 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.
Method Description 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
Method Description colorSets background color gradientSets gradient with any GradientMix type shadowSets single shadow shadowsSets multiple shadows elevationSets Material Design elevation shadow. Values: one, two, three, four, six, eight, nine, twelve, sixteen, twentyFour 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
Method Description 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
Method Description 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.
Method Description rotateSets rotation transform scaleSets scale transform translateSets translation transform skewSets skew transform transformResetResets transform to identity (no effect)
Method Description 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.
Method Description onHoveredCreates a variant for hover state onPressedCreates a variant for pressed state onFocusedCreates a variant for focused state (requires PressableBox or Pressable wrapper) onDisabledCreates a variant for disabled state onEnabledCreates a variant for enabled state (opposite of disabled)
View page source on GitHub