自动将窗口小部件自动换行 [英] Autowrap widgets to new line in flutter
本文介绍了自动将窗口小部件自动换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有5个大小不同的小部件,如果彼此相邻放置,它们会溢出.
I have 5 widgets with different sizes which would overflow if placed next to each other.
我正在寻找一个布局帮助器类,该类将小部件限制在水平空间并自动将小部件自动换行.首先,我正在寻找一个网格视图,但是我宁愿选择一个独立的视图,因为所有元素都有不同的宽度.多行文本字段实际上已经做到了,我只需要对小部件使用相同的方法.有什么想法吗?
I am looking for a layout helper class that limits the widgets to the horizontal space and auto-wraps the widgets instead to a new line. First I was looking for a grid view but prefer instead a view which is independent since all elements have different widths. A multi line text field does actually already that, I just need the same approach with my widgets. Any ideas?
<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'))
]
推荐答案
您需要的是Wrap
小部件:
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'))
],
);
这篇关于自动将窗口小部件自动换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文