How to trigger a pop callback function after the app is restored and the second route is popped?

30 views Asked by At

The issue is I do not have the value yet when the app gets killed. Imagine such a scenario:

  1. User is on route A.
  2. User navigates to route B (route stack is now [A, B])
  3. User moves the app into the background
  4. System kills the app due to battery saving measures or whatever
  5. User re-enters the app (expects to land on the previously visited route)
  6. The app restores the desired route stack ([A, B]).
  7. The user selects an item and pops back to route A.

Example code:

// Step 1: User navigates to RouteB
final result = await GoRouter.of(context).push('RouteB'); // Step 2: User pops back and the returned value is stored to `result`
print(result); // Step 3: Doesn't get triggered

Any idea how to make this work?

0

There are 0 answers