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?

More than 3 years have passed since last update.

【Flutter】画像を使ったダイアログの表示

Last updated at Posted at 2022-06-27

はじめに

Flutterで、よくアプリを最初に開いた時に出る、通知をオンにしてください!みたいな、画像を使ったダイアログを表示したいと思い調べてみたんですが、日本語の記事を見つけられなかったので記事にします。

dialog.dart
void _openDialog() {
    return showDialog(
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          titlePadding: EdgeInsets.zero, //titleの周りについているpaddingを無しにする
          title : Image.network(
          '画像のパス',
            height: 200,  //写真の高さ指定
            fit: BoxFit.cover,  //写真が周りに目一杯広がるようにする
          ),
          content: Text("テキストテキスト"),
          actions: <Widget>[
            TextButton(
              child: Text('OK'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
          ],
        );
      },
    );
  }

上記のコードだと、こんな感じになります!
上の書き方を使えばtitleでもcontentでも画像を使ったダイアログができますので、参考にしていただけたら幸いです!

お疲れ様でした!

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?