skip to Main Content

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.

2

Answers


  1. 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');
      }
    });
    
    Login or Signup to reply.
  2. Use the beamer package for routing.This problem occur in the go router.

    beamer package link

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search