【发布时间】:2019-01-28 07:07:49
【问题描述】:
我正在使用 Flutter BottomSheet 来显示信息,并且希望即使单击后退按钮也始终保持 BottomSheet 可见,并且为了使其正常工作,我已明确处理 onWillPop 并在用户单击后退按钮时保持 BottomSheet 可见,改变路线等
BottomSheet 的高度为 200,我想保留它,但在单击后退按钮时允许应用程序进入后台状态。
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]()));
有什么想法吗?
【问题讨论】:
-
不确定您在寻找什么?你能说清楚吗?
-
@HarshBhikadia 我已经更新了描述,现在有什么想法吗?