WFlex
A utility-first flex layout widget that wraps Flutter's Flex, controlling direction, alignment, spacing, and overflow through className utilities.
WFlex(
className: 'flex-col justify-center items-center gap-4',
children: [
WContainer(className: 'w-10 h-10 bg-blue-500'),
WContainer(className: 'w-10 h-10 bg-green-500'),
],
);
Basic Usage
A spaced row of items: A scrollable column:WFlex is the Wind equivalent of an HTML children along a main axis, controlling direction, justification, cross-axis alignment, gap spacing, and overflow with utility classes. When a Flutter Flex parameter is passed explicitly, it takes precedence over the matching utility class.
WFlex(
className: 'flex-row justify-center items-center gap-4',
children: [
WText('Child 1', className: 'text-red-500'),
WText('Child 2', className: 'text-blue-500'),
],
);
Constructor
WFlex({
Key? key,
dynamic className = '',
Axis? direction,
MainAxisAlignment? mainAxisAlignment,
MainAxisSize? mainAxisSize,
CrossAxisAlignment? crossAxisAlignment,
TextDirection? textDirection,
VerticalDirection verticalDirection = VerticalDirection.down,
TextBaseline? textBaseline,
Clip clipBehavior = Clip.none,
required ListProps
Prop
Type
Default
Description
classNamedynamic''Wind utility class string applied to the flex layout.
childrenListRequired
The widgets laid out along the main axis.
directionAxis?nullMain-axis direction; overrides any
flex-row / flex-col utility.
mainAxisAlignmentMainAxisAlignment?nullMain-axis alignment; overrides any
justify-* utility.
mainAxisSizeMainAxisSize?nullMain-axis size; overrides any
axis-min / axis-max utility.
crossAxisAlignmentCrossAxisAlignment?nullCross-axis alignment; overrides any
items-* utility.
textDirectionTextDirection?nullText direction used to resolve
start / end alignment.
verticalDirectionVerticalDirectionVerticalDirection.downOrder in which children are laid out vertically.
textBaselineTextBaseline?nullBaseline used when cross-axis alignment is baseline.
clipBehaviorClipClip.noneHow overflowing content is clipped.
Supported Utility Classes
Class Type
Example
Documentation
Responsive Design
sm:flex-row, xs:flex-colResponsive Design
Flex Direction
flex-row, flex-colFlex Direction
Justify Content
justify-center, justify-startJustify Content
Align Items
items-center, items-startAlign Items
Axis Sizes
axis-max, axis-minAxis Sizes
Gap (Spacing)
gap-2, gap-[4]Gap (Spacing)
Overflow
overflow-scrollOverflow
Display Classes
hide, show, sm:hideDisplay
Styling Examples
WFlex(
className: 'flex-row justify-between items-center gap-2',
children: [
WText('Left', className: 'text-gray-700 dark:text-gray-200'),
WText('Right', className: 'text-gray-700 dark:text-gray-200'),
],
);
WFlex(
className: 'flex-col gap-4 overflow-scroll',
children: [
WContainer(className: 'w-full h-20 bg-blue-500'),
WContainer(className: 'w-full h-20 bg-green-500'),
WContainer(className: 'w-full h-20 bg-purple-500'),
],
);
Related Documentation