I'm trying to open a page and get returned result with go_router package. In Navigation 1.0 I use this:
final result = await Navigator.push(
context,
MaterialPageRoute(builder: (context) => const SecondRoute()),
);
// handle result
But I can't seem to do it with go_router. Any solution or explaination?
The latest version of go_router package now supports this functionality. To pass data when popping from a screen, you can do this:
context.pop('value');
And to get this value back, your code should look like this:
String? val = await context.pushNamed('secondRoute');
Hope this helps, thank you