LoginSignup
33
19

More than 3 years have passed since last update.

【Flutter2】ElevatedButtonとTextButtonのデザイン12種類をまとめて紹介!

Last updated at Posted at 2021-04-19

Flutter2へのアップデートに伴ってRaisedButtonとFlatButtonが非推奨になりました。その代わりとしてElevatedButtonとTextButtonが推奨になったので、今回はElevatedButtonとTextButtonのデザインをまとめて紹介します。

1.背景に色を付ける

スクリーンショット 2021-04-19 15.01.35.png

     ElevatedButton(
       onPressed: () {},
       child: Text(
         "背景",
       ),
       style: ElevatedButton.styleFrom(
         primary: Colors.red,
       ),

2.アイコン付きボタン

スクリーンショット 2021-04-19 15.02.56.png

     ElevatedButton.icon(
       onPressed: () {},
       label: Text('アイコン'),
       icon: Icon(Icons.star),
     ),

3.非活性のボタン

スクリーンショット 2021-04-19 15.03.11.png

     ElevatedButton(
       onPressed: null,
       child: Text('押せないボタン'),
     ),

4.横丸ボタン

スクリーンショット 2021-04-19 15.03.27.png

     ElevatedButton(
       onPressed: () {},
       child: Text('横丸ボタン'),
       style: ElevatedButton.styleFrom(
         shape: StadiumBorder(),
       ),
     ),

5.サイズの大きいボタン

スクリーンショット 2021-04-19 15.03.59.png

     ElevatedButton(
       onPressed: () {},
       child: Text('大きいボタン'),
       style: ButtonStyle(
         padding: MaterialStateProperty.all(EdgeInsets.all(30)),
         textStyle: MaterialStateProperty.all(TextStyle(fontSize: 25)),
        ),
     ),

6.影がついているボタン

スクリーンショット 2021-04-19 15.04.19.png

     ElevatedButton(
       onPressed: () {},
       child: Text('影付きボタン'),
       style: ElevatedButton.styleFrom(elevation: 10),
     ),

7.丸いボタン

スクリーンショット 2021-04-19 15.04.37.png

     ElevatedButton(
       onPressed: () {},
       child: Text('丸'),
       style: ElevatedButton.styleFrom(shape: CircleBorder()),
     ),

8.外枠付きのボタン

スクリーンショット 2021-04-19 15.05.02.png

     ElevatedButton(
       onPressed: () {},
       child: Text(
         "外枠",
         style: TextStyle(color: Colors.blue),
       ),
       style: ElevatedButton.styleFrom(
         primary: Colors.white,
         side: BorderSide(
           color: Colors.blue,
           width: 2,
         ),
       ),
     ),

9.外枠付きの横丸ボタン

スクリーンショット 2021-04-19 15.05.16.png

     ElevatedButton(
       onPressed: () {},
       child: Text(
         "外枠付き横丸",
         style: TextStyle(color: Colors.blue),
       ),
       style: ElevatedButton.styleFrom(
         shape: StadiumBorder(),
         primary: Colors.white,
         side: BorderSide(
           color: Colors.blue,
           width: 2,
         ),
       ),
     ),

10.文字ボタン

スクリーンショット 2021-04-19 15.05.45.png

     TextButton(
       onPressed: () {},
       child: Text('文字ボタン'),
       style: ButtonStyle(
         foregroundColor:
             MaterialStateProperty.all<Color>(Colors.blue),
       ),
     ),

11.外枠付きの文字ボタン

スクリーンショット 2021-04-19 15.06.12.png

     OutlinedButton(
       onPressed: () {},
       child: Text('外枠付き文字ボタン'),
       style: OutlinedButton.styleFrom(
         side: BorderSide(width: 2, color: Colors.blue),
       ),
     ),

12.横丸の文字ボタン

スクリーンショット 2021-04-19 15.06.37.png

     OutlinedButton(
       onPressed: () {},
       child: Text('横丸文字ボタン'),
       style: OutlinedButton.styleFrom(
         shape: StadiumBorder(),
         side: BorderSide(width: 2, color: Colors.blue),
       ),
     ),
33
19
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
33
19