Flow Layout in flutter example

风格不统一 提交于 2019-12-21 05:07:24

问题


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'),
      ),
  ],
)



回答2:


In Flutter wrap is batter widget for creating layout like your screenshot

Wrap : It can adjust its children according to the space available to it on the Screen. The default arrangement is horizontal (like a row) but you can make it vertical (like a column).

chip : This widget use for create TAG or chips

new Wrap(
  spacing: 5.0, // horizontal gap between chips
  runSpacing: 2.0, // gap between row
  children: <Widget>[
      new Chip(
        label: new Text('One'),
      ),
      new Chip(
        label: new Text('Two'),
      ),
      new Chip(
       label: new Text('Three'),
      ),
      new Chip(
        label: new Text('Four'),
      ),
  ],
)


来源:https://stackoverflow.com/questions/50096734/flow-layout-in-flutter-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!