Flow Layout in flutter example

2019-04-10 08:02发布

问题:

i want to implement flow layout in flutter i found a class called FLOW in sdk but unable to find sample code on how to use it

here is the layout i am trying to achieve

回答1:

Use Wrap instead of Flow.

Flow is for more complicated custom layout. Wrap is what is used to achieve the layout in your screenshot.

new Wrap(
  spacing: 8.0, // gap between adjacent chips
  runSpacing: 4.0, // gap between lines
  children: <Widget>[
      new Chip(
        avatar: new CircleAvatar(backgroundColor: Colors.blue.shade900, child: new Text('AH')),
        label: new Text('Hamilton'),
      ),
      new Chip(
        avatar: new CircleAvatar(backgroundColor: Colors.blue.shade900, child: new Text('ML')),
        label: new Text('Lafayette'),
      ),
      new Chip(
        avatar: new CircleAvatar(backgroundColor: Colors.blue.shade900, child: new Text('HM')),
        label: new Text('Mulligan'),
      ),
      new Chip(
        avatar: new CircleAvatar(backgroundColor: Colors.blue.shade900, child: new Text('JL')),
        label: new Text('Laurens'),
      ),
  ],
)