我想做这个 :

flutter -  flutter 嵌套行MainAxisAlignment-LMLPHP

但是,这实际上是我得到的:

flutter -  flutter 嵌套行MainAxisAlignment-LMLPHP

这是我的代码:

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,因此testtest2 应该的相对两侧

当我删除图像时,我仅返回包含两个RowText,并且设置了mainAxisAlignment,它可以正常工作。似乎嵌套行不能使用此变量

这基本上是我认为的计划:

flutter -  flutter 嵌套行MainAxisAlignment-LMLPHP

最佳答案

截图

flutter -  flutter 嵌套行MainAxisAlignment-LMLPHP

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/

10-11 19:47