Flutter 行列问题
Flutter Row and Column Problems
我在使用 Rows in flutter 时遇到了问题,我想将我的资产放在容器的底部,如何使用 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,)
]
),
)
],
),
),
);
您可以在此处下载 asset/image.svg
http://filesharing24.com/d/DVh
容器有 属性 对齐方式,
你可以像这样使用它
alignment: Alignment(0.0, 0.0), // this means center, range is from -1 to +1
您需要将其设置为 Alignment(-1.0, 1.0)
或者像这样使用它
alignment: Alignment.bottomRight,
你不需要玩弄行轴或列轴,容器 属性 就足够了。
使用其中一种方法来获得准确的位置
我在使用 Rows in flutter 时遇到了问题,我想将我的资产放在容器的底部,如何使用 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,)
]
),
)
],
),
),
);
您可以在此处下载 asset/image.svg http://filesharing24.com/d/DVh
容器有 属性 对齐方式, 你可以像这样使用它
alignment: Alignment(0.0, 0.0), // this means center, range is from -1 to +1
您需要将其设置为 Alignment(-1.0, 1.0) 或者像这样使用它
alignment: Alignment.bottomRight,
你不需要玩弄行轴或列轴,容器 属性 就足够了。 使用其中一种方法来获得准确的位置