试图在Flutter中做这样的事情(我完全是初学者),我不明白如何嵌套一些小部件...... 我试着为浮动的动作按钮和另一个标签的Row()放一个Row(),但它们并不像图片那样居中对齐。我应该用GridView代替吗?
你是对的,但不要用两行,而只用一行。行 但有两个 栏目 内,也可以用行来确定每个孩子的位置,按照 mainAxisAlignment
和 crossAxisAlignment
例如,要将内容居中,使用 MainAxisAlignment.center
如下。
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: [
FloatingActionButton(
onPressed: (){},
child: Icon(Icons.add),
),
Text(
"Test"
)
],
),
SizedBox(width: 16.0),
Column(
children: [
FloatingActionButton(
onPressed: (){},
child: Icon(Icons.add),
),
Text(
"Test"
)
],
),
],
)
如果你想在Flutter中看到更多关于布局的内容,你可以查看 建筑布局 文档中的教程部分。