I'm using showModalBottomSheet
to show a modal material design bottom sheet.
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
...
I'd like this bottom sheet to automatically close (pop?) when Flutter Android app is paused (for example the user is tapping the home button).
How can I do this?
CodePudding user response:
Check WidgetsBindingObserver: https://api.flutter.dev/flutter/widgets/WidgetsBindingObserver-class.html. You can extend it in your modal widget and call pop() when the app state is paused.
CodePudding user response:
Code to detect if user pressed home / tab on flutter? might be a viable solution?
If you detect a pause change in the app lifecycle you can probably then make a navigator.of(context).pop
?