Reputation: 1
Description: I'm encountering an issue with auto_route in my Flutter app, where the current route is unnecessarily rebuilt, leading to an error due to missing arguments. The scenario involves a MainPage that uses TabsRouter to maintain nested navigation. Above my MaterialApp, I have a wrapper that listens to an update service and adds a banner to the app when an update is available.
The problem occurs when the wrapper is notified about an update, which causes the entire route stack, including the current route, to rebuild. Since the current route requires an argument, the rebuild process throws an error stating that the argument cannot be null. This disrupts the user experience and breaks the navigation flow.
https://i.sstatic.net/2iqutuM6.png https://i.sstatic.net/2Fqe0LM6.png
Here is a screenshot from app_router.dart file https://i.sstatic.net/veciWmo7.png
Here is the wrapper implementation included inside the builder of the material app: https://i.sstatic.net/BUL3ngzu.png
How can I prevent auto_route from rebuilding the current route when the wrapper above MaterialApp is notified? What are the best practices for managing routes that require arguments in such scenarios? Any help or suggestions are greatly appreciated.
I have tried to manipulate some bool args related to the rebuild, like:
@override bool get hasPagelessTopRoute => false;
but it did not work either.
Upvotes: 0
Views: 62