Component - Wrap widget
The Wrap widget arranges its child widgets in horizontal or vertical lines and automatically moves to the next line when there is no more space. It is like wrapping text in a paragraph, but for widgets.
The Wrap widget arranges its child widgets in horizontal or vertical lines and automatically moves to the next line when there is no more space. It is like wrapping text in a paragraph, but for widgets.
Wrap ├─ Container (child 1) ├─ Container (child 2) ├─ Container (child 3) ├─ Container (child 4) └─ Container (child 5)
Wrap widget in Flutter?spacing to set horizontal gaps between children.spacing correctly. Options A, B, and D use incorrect property names.Wrap(
spacing: 8,
runSpacing: 12,
children: [
Container(width: 100, height: 50, color: Colors.red),
Container(width: 100, height: 50, color: Colors.green),
Container(width: 100, height: 50, color: Colors.blue),
Container(width: 100, height: 50, color: Colors.yellow),
],
)
Assuming the screen width is 220 pixels.Wrap(
spacing: 10,
children: [
Text('One'),
Text('Two'),
Text('Three'),
],
runSpacing: 15
)runSpacing can be placed after children without error.children list is properly closed, and spacing is correctly used as a property, not inside children.spacing to set horizontal gaps between children and runSpacing to set vertical gaps between lines.padding, margin, mainAxisSpacing, crossAxisSpacing, horizontalSpacing, and verticalSpacing are not valid for Wrap.spacing for horizontal gaps and runSpacing for vertical gaps -> Option BPass the test and this pattern moves unknown