I want to display a simple SnackBar inside Flutter\'s stateful widget. My application creates new instance of MaterialApp with a stateful widget ca
You can do this in three simple steps.
Make sure you have a key for scaffold. You can create that by writing the below code:
final _scaffoldKey = GlobalKey();
2.Now you have to mention this key inside your Scaffold, by writing the below line inside scaffold:
key:_scaffoldKey,
Now you can show snackbar by writing:
final snackBar=SnackBar(
content: Text('Your password has been changed successfully'),
);
_scaffoldKey.currentState.showSnackBar(snackBar);