どうも、ちょげ(@chogetarou)です。
Rowの横幅を設定する方法を紹介します。
方法

Rowの横幅を設定するには、SizedBoxもしくはContainerを使います。
まず、RowをSizedBoxもしくはContainerでラップします。
そして、SizedBoxもしくはContainerの引数「width」に横幅を設定します。
SizedBox(
width: /*横幅*/,
child: Row(
children: [
・・・
],
),
),
SizedBoxもしくはContainerを使うことで、Rowの横幅を設定することが出来ます。
使用例
以下は、使用例です。

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
width: 300,
child: Row(
children: [
Expanded(
child: Container(
color: Colors.blue,
height: 100,
),
),
Expanded(
child: Container(
color: Colors.yellow,
height: 100,
),
),
Expanded(
child: Container(
color: Colors.pink,
height: 100,
),
),
],
),
),
),
);
}
コメント