0
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 3 years have passed since last update.

ElevatedButtonを使ってみる

Last updated at Posted at 2021-02-22

FlutterのUIのお勉強をしたので備忘録を残しておく。

今日のテーマは、
https://api.flutter.dev/flutter/material/ElevatedButton-class.html
ElevatedButtonをいい感じで使ってみたい。

https://api.flutter.dev/flutter/material/RaisedButton-class.html
もともとはRaisedButtonだけど、今はRaisedButtonはobsolete(廃止)になっていて、Flutter1.22.0以降はElevatedButtonを使ってくださいとのことです。

RaisedButtonの説明にもあるように、
FlatButton, RaisedButton, and OutlineButton have been replaced by TextButton, ElevatedButton, and OutlinedButton respectively.
ということなので、

FlatButton → Textbutton
Raisedbutton → ElevatedButton
OutlineButton → OutlinedButton
となったようです。

paddingだったりfontsizeも変えることができて、オリジナルのボタンを作ることができそうですね。

 ElevatedButton(
   onPressed: () {},
   child: Text('いいね'),
   style: ElevatedButton.styleFrom(
     primary: Color(0xFF005731),
     onPrimary: Colors.white,
     padding: EdgeInsets.symmetric(
         horizontal: 100,
         vertical: 5,
      ),
     textStyle: TextStyle(
         fontSize: 15.0,
         fontWeight: FontWeight.bold,
      ),
     shape: RoundedRectangleBorder(
     borderRadius: BorderRadius.circular(10),
   ),
 ),
),

できたボタンはこんな感じです。
スクリーンショット 2021-02-22 21.13.08.png

〈参考〉
https://www.kindacode.com/article/working-with-elevatedbutton-in-flutter/

0
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
0
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?