首页 > 解决方案 > Flutter 行列问题

问题描述

我在颤动中遇到 Rows 问题,我想将我的资产放在容器的底部,如何使用 Row 来做到这一点?我尝试了 mainAxisAlignment: MainAxisAlignment.end 和 cross.end 但不工作...

  Widget build(BuildContext context) {
    double wi = MediaQuery.of(context).size.width;
    return Scaffold(
      body: Container(
        child: Column(
          children: <Widget>[
            Container(
              color: Colors.blue,
              width: wi,
              height: 200,
            ),
            Container(
              width: wi,
              height: 200,
              color: Colors.red,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.end,
                crossAxisAlignment: CrossAxisAlignment.end,
                children: <Widget>[
                  SvgPicture.asset('assets/escapa.svg', semanticsLabel: 'Flask', color: Colors.black, width: 100,height: 100,)
                ]
              ),
              )
          ],
        ),
      ),
    );

SVG1

SVG2

你可以在这里下载asset/image.svg http://filesharing24.com/d/DVh

标签: flutterflutter-layoutflutter-animation

解决方案


容器有属性对齐使用,你可以像这样使用它

alignment: Alignment(0.0, 0.0), // this means center, range is from -1 to +1

您需要将其设置为 Alignment(-1.0, 1.0) 或像这样使用它

alignment: Alignment.bottomRight,

你不需要玩行或列轴,容器属性就足够了。使用其中一种方法来获得准确的位置


推荐阅读