I have a Flutter app that displays an animation. I want the animation to pause if there is an open Drawer or a modal dialog (like showModalBottomSheet) displayed anywhere in the App.
I could handle the events of a specific Drawer directly and manage the state on my own. However, I have multiple drawers in my app that I have to track and it feels like a lot of work. Is there a global place were I can check whether a Drawer (or modal dialog) is open anywhere in the app?
Both
showModalBottomSheetand modal dialogs are pusing a route to theNavigator. This way one can check viaModalRoute.of(context)?.isCurrent != truewhether another route (or dialog) is in front of the current route.Sadly, the open
Drawerof aScaffoldis not a route. However it isn't required to have a key on the scaffold, but one can check viaScaffold.of(context).isDrawerOpenif the next parentDraweris open.By combining the two state I can check whether the animation should be paused.