How do I trigger an action/detect when a user swipes away from a ModalBottomSheet in a Flutter app?

Issue

I have implemented a filter feature in my app, which opens up a modalBottomSheet with some filtering options when a user clicks on a particular button.

I want to get data from my database based on the filters, right when the user clicks/swipes away from the modalBottomSheet.

How do I detect that they’ve done this?
Is there a better way to do this?

Solution

  showModalBottomSheet(
context: context,
builder: (context){
  return Text("example");
}).then((value) => {
  //database things
});

You can use like this. You can detect bottomsheet is closed with this way.

Answered By – MalikSenpai

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *