Can’t pop value when PushReplacement is used in intermediate page

You can give pushReplacement a result to return as if it was popped.

So what you can do in this case is give it again a future (for instance using a Completer) that the original pushing widget can await again for the real result

void method() async {
  final completer = Completer();
  final result = await navigator.pushReplacement(route, result: completer.future);
  completer.complete(result);
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top