Replaced Scaffold.of(context) with ScaffoldMessenger.of(context) (#120)

This commit is contained in:
Md Didarul Islam
2022-10-23 00:13:38 +06:00
committed by GitHub
parent b0d917b05a
commit 467637718c

View File

@ -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 :)"),
)); ));