ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(milliseconds: 4000), // default 4s
content: const Text('Awesome Snackbar!'),
),
);
SnackBar(
behavior: SnackBarBehavior.floating,
margin: EdgeInsets.only(bottom: 100.0),
content: Text("Hello World!"),
);
final snackBar = SnackBar(content: Text('Yay! A SnackBar!'));
// Find the ScaffoldMessenger in the widget tree
// and use it to show a SnackBar.
ScaffoldMessenger.of(context).showSnackBar(snackBar);
final snackBar = SnackBar(
content: Text('Yay! A SnackBar!'),
action: SnackBarAction(
label: 'Undo',
onPressed: () {
// Some code to undo the change.
},
),
);