As simple as it sounds, what’s the current method to display a snackbar through the ScaffoldMessenger after a Navigator.pop into the previous page, where the snackbar is shown on the now current page (previous)?
>Solution :
To return data to the first screen, use the Navigator.pop() method and then show snackbar
ElevatedButton(
onPressed: () {
// Close the screen and return "test!" as the result.
Navigator.of(context).pop();
ScaffoldMessenger.of(context)
..removeCurrentSnackBar()
..showSnackBar(const SnackBar(content: Text('test')));
},
child: const Text('close!'),
)
For more read this article