mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-08-06 14:51:08 +08:00
Replaced Scaffold.of(context) with ScaffoldMessenger.of(context) (#120)
This commit is contained in:
@ -26,7 +26,7 @@ class MyButton extends StatelessWidget {
|
||||
// On pressing the raised button
|
||||
onPressed: () {
|
||||
// show snackbar
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
// set content of snackbar
|
||||
content: Text("Hello! I am SnackBar :)"),
|
||||
// set duration
|
||||
@ -36,7 +36,7 @@ class MyButton extends StatelessWidget {
|
||||
label: "Hit Me (Action)",
|
||||
onPressed: () {
|
||||
// When action button is pressed, show another snackbar
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
"Hello! I am shown becoz you pressed Action :)"),
|
||||
));
|
||||
|
Reference in New Issue
Block a user