Row itemTransaction(BuildContext context, Transaction transaction) {
/// This is the function that will build each item of our transaction list.
return new Row(
children: <Widget>[
new Container(
width: MediaQuery.of(context).size.width / 6,
height: MediaQuery.of(context).size.width / 6,
child: new Image.asset(
(transaction.sent) ? "images/tx_output.png" : "images/tx_input.png",
),
),
new Column(
children: <Widget>[
new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
discoderyText("test"),
discoderyText("test 2"),
],
),
discoderyText("SOME HASH KEY"),
],
),
],
);
}
discoderyText
基本上是自定义文本(即带有颜色)。如您所见,为我的行设置了
mainAxisAlignment: MainAxisAlignment.spaceBetween
,因此test
和test2
应该在的相对两侧。当我删除图像时,我仅返回包含两个
Row
的Text
,并且设置了mainAxisAlignment
,它可以正常工作。似乎嵌套行不能使用此变量。这基本上是我认为的计划:
最佳答案
Row(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width / 6,
height: MediaQuery.of(context).size.width / 6,
child: CircleAvatar(backgroundImage: AssetImage(chocolateImage),),
),
Expanded( // add this
child: Padding(
padding: const EdgeInsets.all(8.0), // give some padding
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min, // set it to min
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("test"),
Text("test 2"),
],
),
Text("SOME HASH KEY HERE"),
],
),
),
),
],
)
关于flutter - flutter 嵌套行MainAxisAlignment,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57873091/