Flutter

Add code after closing modal

flutter-modal-did-complete-en

Add code after closing modal

I wanted to change the status after closing the modal or execute the process of transitioning to another page, so I tried to find out how to do it.

How to detect when a modal is closed

In Swift, we can execute the process when the modal is closed by writing it in the closure of the completion of the following method.

dismiss(animated: , completion: )

On the other hand, in the case of Flutter, we can write the process after closing the modal by writing in whenComplete of the page transition source as shown below.

Navigator.push(
  context,
  MaterialPageRoute(
    builder: (_) => HogePage(),
    fullscreenDialog: true, // if true, navigation type will be modal
  ),
).whenComplete(() {
  // What you want to do after closing the modal
});

Recently, I've been writing Flutter and Swift in parallel, and especially Swift UI and Flutter are often written in a similar way, so I often confuse them....

0

COMMENT

Your email address will not be published.

CAPTCHA