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
|
// On pressing the raised button
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// show snackbar
|
// show snackbar
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
// set content of snackbar
|
// set content of snackbar
|
||||||
content: Text("Hello! I am SnackBar :)"),
|
content: Text("Hello! I am SnackBar :)"),
|
||||||
// set duration
|
// set duration
|
||||||
@ -36,7 +36,7 @@ class MyButton extends StatelessWidget {
|
|||||||
label: "Hit Me (Action)",
|
label: "Hit Me (Action)",
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// When action button is pressed, show another snackbar
|
// When action button is pressed, show another snackbar
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text(
|
content: Text(
|
||||||
"Hello! I am shown becoz you pressed Action :)"),
|
"Hello! I am shown becoz you pressed Action :)"),
|
||||||
));
|
));
|
||||||
|
Reference in New Issue
Block a user