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?

FlutterのElevatedButtonの使い方

0
Posted at

Flutterでボタンを実装する際によく使用されるのがElevatedButtonです。

今回は基本的な使い方から、デザインのカスタマイズまでまとめます。

ElevatedButtonとは?

ElevatedButtonは、立体感(影)のあるボタンを作成するためのWidgetです。

  • タップ可能な主要アクションに使用
  • MaterialDesignに準拠

基本的な使い方

ElevatedButton(
  onPressed: () {
    print('ボタン押下');
  },
  child: Text('ボタン'),
)

スタイルのカスタマイズ

ElevatedButton(
  onPressed: () {},
  style: ElevatedButton.styleFrom(
    backgroundColor: Colors.orange,
    foregroundColor: Colors.white,
    padding: const EdgeInsets.symmetric(vertical: 14),
  ),
  child: Text('ログイン'),
)
  • backgroundColor ボタンの背景色
  • foregroundColor テキストやアイコンの色
  • padding 内側の余白

角丸の設定

shape: RoundedRectangleBorder(
  borderRadius: BorderRadius.circular(12),
),

横幅いっぱいにする

SizedBox(
  width: double.infinity,
  child: ElevatedButton(...),
)

以上で、簡単なElevatedButtonの使い方の説明は完了です。
こちらの内容だけでもある程度のボタンが作れるので、覚えておくと良いと思います。

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?