Skip to content

Instantly share code, notes, and snippets.

@bharathraj-e
Created January 11, 2020 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bharathraj-e/8744b3c4922ee214a1954a898e9389ac to your computer and use it in GitHub Desktop.
Save bharathraj-e/8744b3c4922ee214a1954a898e9389ac to your computer and use it in GitHub Desktop.
A function to create snackbar in flutter
//final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
snackyBar(String content, GlobalKey<ScaffoldState> _scaffoldKey) {
final snackBar = SnackBar(
content: Text(content),
duration: const Duration(seconds: 2),
backgroundColor: Colors.lightBlue,
);
_scaffoldKey.currentState.showSnackBar(snackBar);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment