didPopNext isn't called when poping rootNavigator route back to CupertinoTabView route

Viewed 377

My app is using CupertinoTabScaffold and CupertinoTabView which is using its own navigator (not the root navigator). To open a certain screen which should cover the entire screen (also the tabs) I'm using Navigator.of(context, rootNavigator: true).push. The problem is that for a different purpose I'm tracking screen changes using routeObserver and RouteAware. What I found out is that with respect to the case mentioned above of opening a screen using the root navigator, the didPopNext isn't called when closing the full screen page. I'm assuming it's somehow related to the fact that by closing this screen Flutter is switching from the root navigator back to the CupertinoTabView. Any idea how to solve it?

1 Answers

u should add this:


  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    // add this
    routeObserver.subscribe(this, ModalRoute.of(context));
  }
  @override
  void dispose() {
    routeObserver.unsubscribe(this);
    super.dispose();
  }
final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();
...

MaterialApp(
              navigatorObservers: [routeObserver],
Related