0

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.

Sepehr Marashi
  • 111
  • 1
  • 1
  • 4

2 Answers2

0

You can follow one of the two possible solution:

  1. Dont let page to come back to B from C, You can use something like popUntil
  2. 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
0

Use the beamer package for routing.This problem occur in the go router.

beamer package link

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