从行右开始添加子级

时间:2019-04-30 06:54:02

标签: dart flutter

我正在Flutter设计一个应用程序。我想从右侧而不是默认左侧添加元素。请指导我该怎么做?

1 个答案:

答案 0 :(得分:1)

只需设置文字方向。

    Row(
        textDirection: TextDirection.rtl,
        children: <Widget>[
          Container(
            width: 40,
            height: 40,
            color: Colors.blue,
          ),
          Container(
            width: 40,
            height: 40,
            color: Colors.red,
          ),
          Container(
            width: 40,
            height: 40,
            color: Colors.green,
          )
        ],
      )

带有文字的示例2

Row(
    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
    textDirection: TextDirection.rtl,
    children: <Widget>[
      Text("one"),
      Text("two"),
      Text("three"),
    ],
  )