0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Flutter】Containerに影をつける

Last updated at Posted at 2024-04-03

こんにちは。
今回は、Containerに影をつける方法を紹介します。

方法

スクリーンショット 2023-08-13 20.18.51.png

まず、BoxDecorationのプロパティにboxShadowを設定します。

次に、boxShadowのプロパティを設定します。

  • color: 影の色の指定
  • offset: オフセット、影の位置の指定
  • offset のデフォルト値は、Offset(0, 0)※Widgetと影が、同じ位置で重なっている
  • blurRadius: 影のぼかし具合を調節
  • spreadRadius:影の広がり具合を調節

使用例


class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Center(
          child: Container(
            width: 100,
            height: 70,
            decoration: const BoxDecoration(
              boxShadow: [
                BoxShadow(
                  color: Colors.grey,
                  spreadRadius: 10,
                  blurRadius: 20,
                  offset: Offset(1, 1),
                ),
              ],
              color: Colors.white,
            ),
          ),
        ),
    );
  }
}

実行例

スクリーンショット 2024-04-01 18.15.20.png

最後に

ここまで読んでいただき、ありがとうございました!
いいねしてくれたら、スキップして喜びます:heartpulse:

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?