Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 925
Yosef Avatar asked Dec 14 '25 04:12

Yosef


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],
like image 121
Zhuoyuan.Li Avatar answered Dec 16 '25 16:12

Zhuoyuan.Li



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!