我想在 Flutter 中实现流布局,我在 sdk 中找到了一个名为 FLOW 的类,但找不到有关如何使用它的示例代码
这是我想要实现的布局
最佳答案
使用 Wrap
而不是 Flow
。
Flow
用于更复杂的自定义布局。 Wrap
是用来在你的截图中实现布局的。
Wrap(
spacing: 8.0, // gap between adjacent chips
runSpacing: 4.0, // gap between lines
children: <Widget>[
Chip(
avatar: CircleAvatar(backgroundColor: Colors.blue.shade900, child: Text('AH')),
label: Text('Hamilton'),
),
Chip(
avatar: CircleAvatar(backgroundColor: Colors.blue.shade900, child: Text('ML')),
label: Text('Lafayette'),
),
Chip(
avatar: CircleAvatar(backgroundColor: Colors.blue.shade900, child: Text('HM')),
label: Text('Mulligan'),
),
Chip(
avatar: CircleAvatar(backgroundColor: Colors.blue.shade900, child: Text('JL')),
label: Text('Laurens'),
),
],
)
https://stackoverflow.com/questions/50096734/