Home > Software engineering >  Flutter, Web, navigation 2.0 browser back button
Flutter, Web, navigation 2.0 browser back button

Time:11-23

I found about 10 project of the Navigation 2.0 Flutter Web Sample project through a hard searching.

And it seems that all web components change only on one screen, and no new screens appear. They are internally logically stacked, but they don't look like a browser stack. I've seen every time that the back button doesn't work like a normal website.

Is this not possible in Navigation 2.0?

CodePudding user response:

To handle back button click event, you need to use onPopPage of Navigator on your RouterDelegate.

It will be like

 onPopPage: (route, result) {
        if (!route.didPop(result)) {
          return false;
        }
        notifier.changeScreen(pageName: null); //home
        notifyListeners();
        return true;
      },

Here is my project and practices that will help you.

  • Related