The Wrap widget arranges its children horizontally or vertically, wrapping them to the next line or column when there isn’t enough space. It’s similar to a Row or Column, but supports automatic wrapping.
Source Code
Wrap(
spacing: 8.0,
runSpacing: 12.0,
children: List.generate(8, (index) {
return Chip(
label: Text('Item $index'),
backgroundColor: Colors.teal[100 * ((index % 9) + 1)],
);
}),
)
Ai Code Analizer
🎨 Important Properties
| Property | Description |
|---|---|
direction | Axis of layout (Axis.horizontal or Axis.vertical) |
spacing | Horizontal space between children |
runSpacing | Vertical space between lines (or runs) |
alignment | Aligns items in the main axis (start, center, end, etc.) |
runAlignment | Aligns each wrap “line” in the cross-axis |
crossAxisAlignment | How items are aligned vertically (or horizontally if vertical) |
