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 1 year has passed since last update.

Flutter 〜様々なボタンの表示 ElevatedButton,TextButton, OutlinedButton, IconButton, FloatingActionButton〜

Posted at

Columで各ボタンウィジェットを縦に並べてみる。
上から
ElevatedButton
TextButton
OutlinedButton
IconButton
FloatingActionButton

image.png

import 'package:flutter/material.dart';

void main() {
  // デバッグ用の関数。ボタンがクリックされたときにコンソールにメッセージを表示します。
  debugFunction() {
    debugPrint('ボタンがクリックされました');
  }

  // 背景色が緑のElevatedButtonを作成します。
  final button1 = ElevatedButton(
    onPressed: debugFunction,
    child: Text('ElavatedButton'),
    style: ElevatedButton.styleFrom(backgroundColor: Colors.green),
  );

  // TextButtonを作成します。
  final button2 =
      TextButton(onPressed: debugFunction, child: Text('TextButton'));

  // OutlinedButtonを作成します。
  final button3 =
      OutlinedButton(onPressed: debugFunction, child: Text('OutlinedButton'));

  // アイコン付きのIconButtonを作成します。
  final button4 = IconButton(
    onPressed: debugFunction,
    icon: Icon(Icons.control_point),
  );

  final button5 =
      FloatingActionButton(onPressed: debugFunction, child: Text('FAB'));

  // MaterialAppウィジェットを使用して、アプリのルートを定義します。
  final app = MaterialApp(
    home: Scaffold(
      // Scaffoldウィジェットを使用して、基本的なマテリアルデザインのレイアウトを提供します。
      body: Center(
        // Columnウィジェットを使用して、ボタンを垂直に並べます。
        child: Column(mainAxisSize: MainAxisSize.min, children: [
          button1,
          button2,
          button3,
          button4,
          button5,
        ]),
      ),
    ),
  );

  // アプリケーションを起動します。
  runApp(app);
}
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?