ResponsiveWrap class
A smart wrapping widget that displays children horizontally and automatically wraps to the next line when space runs out.
Unlike ResponsiveFlex which switches entirely between Row and Column, ResponsiveWrap wraps items line by line — perfect for chips, tags, and button groups.
Performance Design
- Uses Wrap internally (Flutter's optimized layout algorithm)
- Spacing values are scaled via
.sonly once per build - No LayoutBuilder needed — Flutter's Wrap handles overflow natively
Example
ResponsiveWrap(
spacing: 12,
runSpacing: 8,
children: [
FilterChip(label: Text('All')),
FilterChip(label: Text('Clothes')),
FilterChip(label: Text('Electronics')),
FilterChip(label: Text('Shoes')),
],
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- ResponsiveWrap
Constructors
-
ResponsiveWrap({Key? key, required List<
Widget> children, double spacing = 8.0, double runSpacing = 8.0, WrapAlignment alignment = WrapAlignment.start, WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.center, WrapAlignment runAlignment = WrapAlignment.start, Axis direction = Axis.horizontal, bool scaleSpacing = true, EdgeInsetsGeometry? padding}) -
Creates a ResponsiveWrap.
const
Properties
- alignment → WrapAlignment
-
Alignment of children along the main axis.
final
-
children
→ List<
Widget> -
The children to layout.
final
- crossAxisAlignment → WrapCrossAlignment
-
Alignment of children along the cross axis within each run.
final
- direction → Axis
-
The direction in which children are laid out.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- padding → EdgeInsetsGeometry?
-
Optional padding around the entire wrap.
final
- runAlignment → WrapAlignment
-
Alignment of runs within the overall wrap.
final
- runSpacing → double
-
Vertical spacing between lines (scaled via
.s).final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scaleSpacing → bool
-
Whether to scale spacing and runSpacing using Scalify.
Set to
falseif you want fixed pixel values. Default:true.final - spacing → double
-
Horizontal spacing between children (scaled via
.s).final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited