如何相对设置图像位置

时间:2019-11-14 09:58:33

标签: flutter dart

这是Flutter Layout的基本问题。

到目前为止,我使用Row放置了一些图像。

但是我要做的是将图像放在“右下”和“左下”。

如何通过Flutter布局系统完成此任务?

Row(
  children: [
    Image.asset('images/pic1.png',
      height:50,
      left:50, // this member doesnt exist.
      bottom:10// this member doesnt exist.
    ),
    Image.asset('images/pic2.png',
      height:50
      right:50,// this member doesnt exist.
      bottom:10,// this member doesnt exist.
    )
  ]
),

1 个答案:

答案 0 :(得分:0)

您可以使用Align。例如,对于右下角,您可以这样操作:

Align(
  alignment: Alignment.bottomRight,
  child: YourWidget(),
)

请注意,Align会填满它可以获得的所有空间,因此您可能希望将其限制在SizedBoxContainer内!

Here是您需要了解的有关Alignment类的所有内容,这是您传递给alignment构造函数的Align参数的原因。

相关问题