Autowrap widgets to new line in flutter

The Wrap widget is what you need:

return Wrap(
      children: <Widget>[
        new RaisedButton(child: const Text('Foo')),
        new RaisedButton(child: const Text('Foo Bar')),
        new RaisedButton(child: const Text('Foo Bar Bas')),
        new RaisedButton(child: const Text('F')),
        new RaisedButton(child: const Text('B'))
      ],
    );

Also you can add the properties runSpacing and spacing to your Wrap widget to give more space between your items in horizontal and vertical.

Wrap(
            runSpacing: 5.0,
            spacing: 5.0,

enter image description here

Leave a Comment