I am using Flutter BottomSheet to display info, and would like to keep BottomSheet always visible even when back button is clicked, and to make it work I have explicitly handled onWillPop and to keep the BottomSheet in view even when user clicks back button, changing the route etc
The BottomSheet has a height of 200, and I want to keep it and yet allow the app to go background state when back button is clicked.
Widget _buildBody(context) => WillPopScope(
onWillPop: () async {
if(navigatorKey.currentState.canPop()) {
navigatorKey.currentState.pop();
return false;
}else {
// Returning true will remove the BottomSheet when back button is pressed, and if you press the back button one more time, the app will go to background state
// return true;
}
},
child: MaterialApp(
navigatorKey: navigatorKey,
onGenerateRoute: (route) => pagesRouteFactories[route.name]()));
Any ideas?