[Flutter]Columnに影をつけるには?

Flutter

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

Columnに影をつける方法を紹介します。

スポンサーリンク

方法

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

Columnに影をつけるには、Containerを使います。

まず、ContainerでColumnをラップします。

次に、Containerの引数「decoration」にBoxDecorationを指定します。

そして、BoxDecorationの引数「boxShadow」で影の設定をします。

Container(
  decoration: BoxDecoration(
    boxShadow: [
      BoxShadow(
        /*影の設定*/
      ),
    ],
  ),
  child: Column(
    children: [
      ・・・
    ],
  ),
),

これでColumnに影がつきます。

使用例

以下は、使用例です。

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: Container(
          decoration: BoxDecoration(
            boxShadow: [
              BoxShadow(
                spreadRadius: 1,
                blurRadius: 3,
                color: Colors.grey,
                offset: Offset(18, 18),
              ),
            ],
          ),
          child: Column(
            children: [
              Expanded(
                child: Container(
                  color: Colors.white,
                ),
              ),
            ],
          ),
          padding: EdgeInsets.all(20),
        ),
      ),
    );
  }

コメント

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