How run code after showDialog is dismissed in Flutter?

前端 未结 7 1440
心在旅途
心在旅途 2021-02-05 01:11

How to update the Homepage just after the showDialog() is dismissed/disposed? Doesn\'t seem like it has an onDispose() function.

Found another

7条回答
  •  被撕碎了的回忆
    2021-02-05 01:36

    Noticed a couple of the above answers were a bit out of date due to the "child" construct used with the AlertDialog object being deprecated now.

    Here is what I use now instead for a blocking alert dialog:

              showDialog(
                context: context,
                builder: (BuildContext context) {
                  // return object of type Dialog
                  return AlertDialog(
                    title: new Text("Conversation Request"),
                    content:
                        new Text("Have a conversation with this person"),
                    actions: [
                      // usually buttons at the bottom of the dialog
                      new FlatButton(
                        child: new Text("Accept"),
                        onPressed: () {
                          performAccept();
                        },
                      ),
                      new FlatButton(
                        child: new Text("Ignore"),
                        onPressed: () {
                          performIgnore();
                        },
                      )
                    ],
                  );
                },
              )
    

提交回复
热议问题