showSnackbar function

void showSnackbar({
  1. required BuildContext context,
  2. String title = '',
  3. String message = '',
  4. ContentType contentType = ContentType.success,
})

Implementation

void showSnackbar({
  required BuildContext context,
  String title = '',
  String message = '',
  ContentType contentType = ContentType.success,
}) {
  final snackBar = SnackBar(
    /// need to set following properties for best effect of awesome_snackbar_content
    elevation: 0,
    behavior: SnackBarBehavior.floating,
    backgroundColor: Colors.transparent,
    content: AwesomeSnackbarContent(
      title: title,
      message: message,

      /// change contentType to ContentType.success, ContentType.warning or ContentType.help for variants
      contentType: contentType,
    ),
  );

  ScaffoldMessenger.of(context)
    ..hideCurrentSnackBar()
    ..showSnackBar(snackBar);
}