showSnackBar method
- dynamic content
Shows a SnackBar with the given content
in the current Scaffold.
If the content
is a String, it will be converted to a Text widget.
If the content
is not a SnackBar and is a Widget, it will be wrapped
in a SnackBar widget.
If the content
is a SnackBar, it will be shown using the scaffoldMessenger.
If none of the above conditions are met, the content
will be converted to
a String and shown as a SnackBar.
Returns the ScaffoldFeatureController for the shown SnackBar.
Implementation
ScaffoldFeatureController<SnackBar, SnackBarClosedReason> showSnackBar(dynamic content) {
if (content is String) content = content.asText();
if ((content is! SnackBar) && content is Widget) {
content = SnackBar(content: content);
}
if (content is SnackBar) {
return scaffoldMessenger.showSnackBar(content);
}
return showSnackBar("$content");
}