After an action (for example, "save"), user is returned to another page in the app.
I want to show a snackbar on the new page to confirm the action, but don't want it to show if the user navigated there without the action. So for example, if user saves "thing", the app sends them to "things" main page and shows the "saved" snackbar, but if they go to "things" main page some other way, I don't want the "saved" snackbar to be there.
Here is my code on the panel that saves, but the destination page does not show the snackbar — regardless where I place the snackbar (before or after navigation), it does not execute the snackbar.
Future<Null> saveThatThing() async {
thing.save();
thing = new Thing();
Navigator.of(context).push(getSavedThingRoute());
Scaffold.of(context).showSnackBar(
new SnackBar(
content: new Text('You saved the thing!'),
),
);
}
What is the best way to do this?
See Question&Answers more detail:os