如何管理行中的小部件(颤动)一个在左边,另一个在右边
How to manage widget in row(flutter) one to the left and another one to the right
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Icon(Icons.money_rounded,size: 30,),
Text('เงินสด',
style: TextStyle(
color: Colors.grey[700],
fontWeight: FontWeight.bold,
),
),
Text('1000 THB',
style: TextStyle(
color: Colors.grey[700],
fontWeight: FontWeight.bold,
),
),
RaisedButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
onPressed: (){
},
child: Icon(Icons.add_outlined),
),
],
)
根据代码,他们将这一行中的所有小部件平均分配(bc MainAxisAlignment.spaceAround),就像这样
--------------------------------------------
|...图标...|...文本...|...文本...|..按钮..|
--------------------------------------------
但我想将第一个图标和第一个文本分组到该行的左侧,另外两个分组到该行的右侧。
像这样
------------------------------------------
|图标 |文本|................|文本|按钮 |
------------------------------------------
抱歉,我不会画,所以我希望你知道我想说什么。
在它们之间放置 Spacer()
小部件,这样就可以了。
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Icon(Icons.money_rounded,size: 30,),
Text('เงินสด',
style: TextStyle(
color: Colors.grey[700],
fontWeight: FontWeight.bold,
),
),
Text('1000 THB',
style: TextStyle(
color: Colors.grey[700],
fontWeight: FontWeight.bold,
),
),
RaisedButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
onPressed: (){
},
child: Icon(Icons.add_outlined),
),
],
)
根据代码,他们将这一行中的所有小部件平均分配(bc MainAxisAlignment.spaceAround),就像这样
--------------------------------------------
|...图标...|...文本...|...文本...|..按钮..|
--------------------------------------------
但我想将第一个图标和第一个文本分组到该行的左侧,另外两个分组到该行的右侧。
像这样
------------------------------------------
|图标 |文本|................|文本|按钮 |
------------------------------------------
抱歉,我不会画,所以我希望你知道我想说什么。
在它们之间放置 Spacer()
小部件,这样就可以了。