Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter Android back按钮在Flatter中弹出另一个页面后没有调用onWillPop_Flutter_Dart_Flutter Navigation - Fatal编程技术网

Flutter Android back按钮在Flatter中弹出另一个页面后没有调用onWillPop

Flutter Android back按钮在Flatter中弹出另一个页面后没有调用onWillPop,flutter,dart,flutter-navigation,Flutter,Dart,Flutter Navigation,我有一个BottomNavigationBar和一个IndexedStack,我试图在每个导航选项卡中实现嵌套导航。例如,“搜索”选项卡有自己的Navigator包装在WillPopScope中,如下所示: WillPopScope( onWillPop: () async { BottomNavigationBar navigationBar = navigationKey.currentWidget; if (Navigator.canPop(navigatorConte

我有一个
BottomNavigationBar
和一个
IndexedStack
,我试图在每个导航选项卡中实现嵌套导航。例如,“搜索”选项卡有自己的
Navigator
包装在
WillPopScope
中,如下所示:

WillPopScope(
  onWillPop: () async {
    BottomNavigationBar navigationBar = navigationKey.currentWidget;
    if (Navigator.canPop(navigatorContext)) {
      Navigator.pop(navigatorContext);
    } else if (searchBarController.isOpen) {
      searchBarController.close();
    } else {
      BottomNavigationBar navigationBar = navigationKey.currentWidget;
      navigationBar.onTap(0);
    }
    return false;
  },
  child: Navigator(
    onGenerateRoute: (settings) {
      return MaterialPageRoute(
        settings: settings,
        builder: (context) {
          switch (settings.name) {
            case '/':
              return buildRootPage();
            case '/movie':
              return MoviePage();
            default:
              return null;
          }
        },
      );
    },
  ),
);
将页面推到该搜索选项卡并弹出后,后退按钮不再调用
onWillPop
方法,并且不会发生任何事情。然而,每当我点击屏幕上的任何地方,后退按钮就会再次开始工作


什么可能导致这种情况?

确保Willposcope小部件是顶部小部件,而不是MaterialApp或Scaffold的子部件