[Flutter]Containerの大きさを設定するには?

Flutter

どうも、ちょげ(@chogetarou)です。

Containerの大きさを設定する方法を紹介します。

スポンサーリンク

方法

インターフェース, インターネット, プログラム, ブラウザ, Www

Containerの大きさを設定するには、引数「width」に横幅、引数「height」に高さを指定します。

Container(
  height: /*高さ*/,
  width: /*横幅*/,
),
使用例
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            Container(
              height: 100,
              width: 100,
              color: Colors.red,
            ),
            Container(
              height: 200,
              width: 200,
              color: Colors.red,
            ),
            Container(
              height: 300,
              width: 300,
              color: Colors.red,
            ),
          ],
        ),
      ),
    );
  }

コメント

タイトルとURLをコピーしました