[Flutter]Containerの高さを最大にするには?

Flutter

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

Containerの高さを最大にする方法を紹介します。

スポンサーリンク

方法

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

Containerの高さを最大にするには、引数「height」に「double.infinity」を指定します。

Container(
  height: double.infinity,
),

また、ContainerをColumn内で使う場合には、ContainerをExpandedの「child」に指定します。

Column(
  children: [
    Expanded(
      child: Container(
        height: double.infinity,
      ),
    ),
  ],
),

以下は、使用例です。

使用例
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          children: [
            Expanded(
              child: Container(
                height: double.infinity,
                color: Colors.blue,
              ),
            ),
          ],
        ),
      ),
    );
  }

コメント

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