3
1

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 2023-08-22

今回はflutterで使われるContainerの角を丸くする方法を紹介したいと思います。

1.decoration

Containerの背景色、境界線、角の丸み、影などを定義するため[BoxDecoration]のインスタンスを[decoration]プロパティに指定します。

Container(
        decoration:BoxDecoration()
)

2.borderRadius

borderRadiusを使用して、角を丸くします。
BorderRadius.circular()メソッドに半径の値を指定することで、角が丸くなります。

Container(
        decoration:BoxDecoration(
            borderRadius: BorderRadius.circular(~),//()の中は角の半径を指定
    )
)

3.例

例1

Container(
                height: 150,
                width: 200,
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(20), 
                    color: Colors.red),
              ),

スクリーンショット 2023-08-16 19.01.37.png

例2

Container(
                height: 100,
                width: 250,
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(50),
                    color: Colors.blue),
              ),

スクリーンショット 2023-08-16 19.05.01.png

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?