let's say I navigate from page a with context.push() and pass extra to page b. then if I navigate to page c and then press the browser back button to go back to page b now extra is null and page shows error. any solutions? I think we can use query parameters but it brings up security problems.
Asked
Active
Viewed 622 times
2 Answers
0
You can follow one of the two possible solution:
- Dont let page to come back to B from C, You can use something like
popUntil
- When coming back to B from C override the naviagetion such that you send the extra object along with it. So that B has extra value
Edit:
Presently there is no way to achieve this using go_router
. You can use go_router_flow
which is exactly like go_router
with this pop with value feature.
final bool? result = await context.push<bool>('/page2');
WidgetsBinding.instance.addPostFrameCallback((_) {
if(result){
print('Page returned $result');
}
});

krishnaacharyaa
- 14,953
- 4
- 49
- 88
-
it's not about just going back to page B in every ways. I mean when I press the back button in the app bar every thing works fine but when I press the browser back button I loose the extra. – Sepehr Marashi Jan 02 '23 at 09:30
-
Please find my edit. Hope it helps – krishnaacharyaa Jan 03 '23 at 13:59
0
Use the beamer package for routing.This problem occur in the go router.

Eric Aya
- 69,473
- 35
- 181
- 253

Muhammad Talha
- 1
- 2