どうも、ちょげ(@chogetarou)です。
Row自体を右に寄せる方法を紹介します。
方法

Row自体を右に寄せるには、Alignウェジェットを使います。
まず、RowをAlignでラップします。
そして、Alignの引数「alignment」に次のいずれかの値を指定します。
- Alignment.centerRight : 中央右
- Alignment.bottomRight:右下
- Alignment.topRight : 右上
Align(
alignment: Alignment.centerRight, //Alignemnt.bottomRight, Alignment.topRight
child: Column(
children: [
・・・
],
),
),
Alignを使えば、Row自体を右に寄せることが出来ます。
使用例
以下は、使用例です。

@override
Widget build(BuildContext context) {
return Scaffold(
body: Align(
alignment: Alignment.centerRight,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
color: Colors.blue,
height: 100,
width: 100,
),
Container(
color: Colors.yellow,
height: 100,
width: 100,
),
Container(
color: Colors.pink,
height: 100,
width: 100,
),
],
),
),
);
}
コメント