gpt4 book ai didi

flutter 表结构

转载 作者:IT王子 更新时间:2023-10-29 06:35:12 27 4
gpt4 key购买 nike

我想得到这个结构:

-----------------------------------------------------------------------------------
item 1 item 2
item 3 item 4
-----------------------------------------------------------------------------------

基本上我需要有一个,每个有2个和2个,但这是我得到的效果:

这是我的代码:

new Container(
decoration: new BoxDecoration(color: Colors.grey),
child: new Row(
children: <Widget>[

new Column(
children: <Widget>[
new Container(
decoration: new BoxDecoration(color: Colors.red),
child: new Text("item 1"),
),
new Container(
decoration: new BoxDecoration(color: Colors.amber),
child: new Text("item 3"),
),
],
),

new Column(
children: <Widget>[
new Container(
decoration: new BoxDecoration(color: Colors.green),
child: new Text("item 2"),
),
new Container(
decoration: new BoxDecoration(color: Colors.teal),
child: new Text("item 4"),
)
],
)

],
),
)

我希望每个 column 占用 width 可用空间的一半。在 Android 上,我会使用 weight 属性,仅此而已。

最佳答案

我建议使用表格小部件来保持一致性和方便性,因为嵌套的行和列可能会变得有点凌乱且缩进太多。

https://docs.flutter.io/flutter/widgets/Table-class.html

   ...
Table(children: [
TableRow(children: [
Text("item 1"),
Text("item 2"),
]),
TableRow(children:[
Text("item 3"),
Text("item 4"),
]),
]);

关于 flutter 表结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51118946/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com