showSnackBar static method

void showSnackBar({
  1. required BuildContext context,
  2. required String message,
  3. Duration? duration,
  4. Color? backgroundColor,
  5. SnackBarBehavior behavior = SnackBarBehavior.floating,
})

Show Snackbar

Implementation

static void showSnackBar(
    {required BuildContext context,
    required String message,
    Duration? duration,
    Color? backgroundColor,
    SnackBarBehavior behavior = SnackBarBehavior.floating}) {
  if (duration == null) duration = Duration(seconds: 2);
  if (backgroundColor == null) {
    backgroundColor = theme()!.secondaryHeaderColor;
  }
  ScaffoldMessenger.of(context).showSnackBar(SnackBar(
    content: Text(message),
    backgroundColor: backgroundColor,
    behavior: behavior,
    duration: duration,
  ));
}