どうも、ちょげ(@chogetarou)です。
Cardに最小の横幅を設定する方法を紹介します。
方法
Cardに最小の横幅を設定するには、BoxConstraintsを使います。
まず、CardをBoxContrainstsのchildに指定します。
次に、BoxConstraintsの引数「constraints」にBoxConstraintsを指定します。
そして、BoxConstraintsの引数「minWidth」に最小の横幅を設定します。
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ConstrainedBox(
constraints: BoxConstraints(
minWidth: 200, //最小の横幅
),
child: Card(
child: Container(
height: 30,
width: 1,
child: Text('Flutter'),
color: Colors.yellow,
),
),
),
),
);
}
コメント