'Pass RouteSettings between nested navigators

I'm trying to set a notification feature on my Flutter app.

My app is made of a top root Navigator, which handles login page or other simple pages, and contains 4 (or 5, given the user rights) tabs, each one having its own Navigator to handle nested routes (e.g. offers, offers/{id}, categories, categories/{id}).

My problem is : how do I pass the top root navigator RouteSettings.arguments to the nested Navigator ?

Concrete exemple : I send a notification promoting a specific offer with a custom message to display on the page, so in the Firebase instance, I will get parameters before pushing the requested route making

Navigator.of(context).pushNamed('offers/specificOffer', OfferPageArguments(1, "hi this is my message"));

The root Navigator will handle this perfectly, but then, will delegate the correct route and arguments to the nested navigator.. So how do you provide those data ?

I thought of replacing the nested Navigator (RouteSettings settings) => onGenerateRoute(settings) with (RouteSettings settings) => onGenerateRoute(rootNavigatorSettings)

But this will only work with the first generated route. Then, making NestedNavigator.of(context).pushNamed('/specificOffers', OfferPageArgs(2, "new message")) will not provide the given arguments.

Did someone already faced the same problem or could give me a different way to achieve this ?

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source