auto_route_library
auto_route_library copied to clipboard
[Web] Navigate back to page with required argument
I have a page structure where I use arguments to provide data between screens inside of my authentication flow. The screens are reused from other locations inside of the app so they need to be able to accept arguments. The routes are not nested.
simplified page structure:
- welcome
- sign in (argument)
- sign up (argument)
- forgot password (argument)
...
When I navigate from welcome
to sign in
and from there to forgot password
and then press the back button the browser seems to loose the argument that is required by sign in
.
After pressing the back button on forgot password
I get routed back to welcome
with this error message:
Error:
SignInRouteArgs can not be null because the corresponding page has a required parameter
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 294:49 throw_
packages/auto_route/src/route/route_data.dart 99:9 argsAs
packages/auth/src/navigator/auth_router.gm.dart 57:29 <fn>
packages/auto_route/src/router/controller/root_stack_router.dart 169:19 [_pageBuilder]
packages/auto_route/src/router/controller/routing_controller.dart 1547:29 [_addEntry]
packages/auto_route/src/router/controller/routing_controller.dart 1522:29 _pushAllGuarded
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50 <fn>
dart-sdk/lib/async/zone.dart 1661:54 runUnary
dart-sdk/lib/async/future_impl.dart 156:18 handleValue
dart-sdk/lib/async/future_impl.dart 840:44 handleValueCallback
dart-sdk/lib/async/future_impl.dart 869:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 458:9 callback
dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:15 <fn>
I would prefer not to use query parameters because there might be data that I don't want to expose in the url (our onboarding is really long and complex).
Thanks a lot for your help!
@Milad-Akarie Could this be an issue related to the way the browser history is saved? I had the same issue when using go_router where I had to provide encoding and decoding methods for data provided as extra argument.
I am facing the same issue with declarative router..
im facing this issue too, i got this issue when i navigate back from previous screen that require an argument.
i'm running into the same issue...would be awesome to get that fixed asap, thanks!
@Milad-Akarie any updates on this issue? This issue causes lots of problems in our production web app.
Hey @peer-f I suggest you adjust your design so you don't pass objects when working with web, even if somehow I support this usecase you still have to handle page refresh and deeplinking.
@Milad-Akarie thanks for the quick response!
So there is no way to store this data internally like go_router does?
Our application shares most of its business logic between mobile and web only the UI differs so I'd have to change this for the whole application.
I think the way arguments are handled in auto_route is really great which is why we use it most of the time.
Could this be solved if there was a way to provide serialization/deserialization logic for each query parameter? This way both page refresh and deeplinking could be achieved.