flutterdartflutter-navigation

Navigation using named routes, but so that one element (widget) is always on top


I don't know how to make navigation so that one element (widget) always stays on top. And for it to work with named routes

As you can see in the video, I would like the bottom (purple) panel to always be on top. I use named routes and when I reload the page, another window pops up.And the url path disappears immediately.

Who can help and what information should be provided?


Solution

  • I am not sure I understand you, but if you would like a screen, e.g. initial route, to always be visible when you navigate into another screen, then you can use PageRouteBuilder with a false opaque to achieve that;

      Navigator.of(ctx).push(
        PageRouteBuilder(
            opaque: false,
            pageBuilder: (BuildContext context, _, __) {
              return YourWidgetScreen();
            }),
      );