Dee*_*lho 0 row flutter flutter-layout
我试图在颤振中包装一些内容但没有成功。我发现我不能像使用 Chips 或 Text 小部件那样包装行。有谁知道为什么?
这是三组 Rows ,每组都有一个 Icon 和一个 Text ,并排放置。但是在较小的屏幕中它会溢出,因为没有足够的空间(宽度)。
我希望当当前行中的空格结束时,最后一组行(一个图标和一个标签)跳到下一行。
谢谢
我试图用容器包装行,但没有奏效。
Row(
children: <Widget>[
Wrap(
children: <Widget>[
Row(
children: <Widget>[
Text('long text 1'),
Text('an icon here'),
],
),
Row(
children: <Widget>[
Text('Anoter Label'),
Text('Anoter icon'),
],
),
// I want this row to jump to next line when there is not space in
// current line
Row(
children: <Widget>[
Text('More Text'),
Text('Moire icon'),
],
),
],
)
],
),
Run Code Online (Sandbox Code Playgroud)
当我在较小的屏幕上时,带有标题的图像会调整大小并适合。但是图像上方的标签和图标溢出了。所以我喜欢最后一组图标/标签与 $ simbol e 价格的那个,跳到一个新行。我可以在仅使用文本小部件时换行并且它可以工作,但是随后我松开了像 mainAxisAlignment: MainAxisAlignment.spaceAround 这样的行的对齐方式
key*_*key 12
更新:这在某种程度上是一个解决方案
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Expanded(
child: Wrap(
children: <Widget>[
Icon(Icons.alarm),
Text('60 Minutes'),
],
),
),
Expanded(
child: Wrap(
children: <Widget>[
Icon(Icons.shop),
Text('Lorem ipsumssssssssssssssssssssssssssssssss'),
],
),
),
Expanded(
child: Wrap(
children: <Widget>[
Icon(Icons.attach_money),
Text('Very expensive'),
],
),
)
],
);
Run Code Online (Sandbox Code Playgroud)
...
你可以这样做
Row(
children: <Widget>[
Expanded(
child: Wrap(
children: <Widget>[
Text('long text 1'),
Text('an icon here'),
Text('Anoter Label'),
Text('Anoter icon'),
// I want this row to jump to next line when there is not space in
// current line
Text('More Text'),
Text('Moire icon'),
],
),
)
],
),
Run Code Online (Sandbox Code Playgroud)
或这个
Row(
children: <Widget>[
Expanded(
child: Wrap(
children: <Widget>[
Row(
children: <Widget>[
Text('long text 1'),
Text('an icon here'),
],
),
Row(
children: <Widget>[
Text('Anoter Label'),
Text('Anoter icon'),
],
),
// I want this row to jump to next line when there is not space in
// current line
Row(
children: <Widget>[
Text('More Text'),
Text('Moire icon'),
],
),
],
),
)
],
),
Run Code Online (Sandbox Code Playgroud)
小智 5
Row 的宽度由mainAxisSize属性决定。如果mainAxisSize属性为MainAxisSize.max,则 Row 的宽度是传入约束的最大宽度。如果mainAxisSize
属性为MainAxisSize.min,则 Row 的宽度是受传入约束约束的子项的宽度总和。
要解决您的问题,只需将mainAxisSize属性 设置为MainAxisSize.minRow Widget
| 归档时间: |
|
| 查看次数: |
3591 次 |
| 最近记录: |