Wrap
Wrap is a widget in Flutter that allows you to display a set of widgets in a horizontal or vertical manner. It automatically wraps the widgets to the next line as needed.
Example
Wrap(
direction: Axis.horizontal,
children: [
Container(height: 50, width: 50, color: Colors.red),
Container(height: 50, width: 50, color: Colors.green),
Container(height: 50, width: 50, color: Colors.blue),
Container(height: 50, width: 50, color: Colors.yellow),
],
)This code will display the four containers in a row. If the screen width is not large enough to display all four containers, it will automatically wrap the remaining containers to the next line.
Attributes
direction: The direction in which the widgets should be wrapped, either Axis.horizontal or Axis.vertical.
alignment: The alignment of the wrapped widgets within the available space.
spacing: The amount of space to place between each wrapped widget.
runAlignment: The alignment of the wrapped lines of widgets within the available space.
runSpacing: The amount of space to place between each wrapped line of widgets.
crossAxisAlignment: The alignment of the wrapped widgets perpendicular to the wrapping direction.
textDirection: The directionality of the text within the wrapped widgets.
verticalDirection: The vertical direction of the wrapped widgets.