12
8

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

Flutterでダイアログを閉じる

Posted at

ダイアログを閉じる方法

Navigator.pop(context);

で閉じれます。

サンプル

            var alert = new AlertDialog(
              title: new Text("グループを作成する"),
              actions: <Widget>[
                new FlatButton(onPressed: () {
                  Navigator.pop(context);
                  return Navigator.pushNamed(context, "/create_group");
                }, child: new Text("作成する")),
              ],
            );
            showDialog(
                context: context,
                builder: (BuildContext context) {
                  return alert;
                });

このパターンだと「作成する」ボタンをタップしたときに画面遷移して戻って来たときにはダイアログは閉じられているようになります。

12
8
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
12
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?