showSnackBar method

void showSnackBar({
  1. required String message,
  2. Color backgroundColor = Colors.green,
  3. Color foregroundColor = Colors.white,
  4. Duration displayDuration = const Duration(seconds: 4),
  5. bool showCloseIcon = true,
})

showSnackBar shows a snackbar message.
backgroundColor is green by default.
foregroundColor is white by default.

Implementation

void showSnackBar(
    {required String message,
    Color backgroundColor = Colors.green,
    Color foregroundColor = Colors.white,
    Duration displayDuration = const Duration(seconds: 4),
    bool showCloseIcon = true}) {
  ScaffoldMessenger.of(this).showSnackBar(SnackBar(
    content: Text(message, style: TextStyle(color: foregroundColor)),
    backgroundColor: backgroundColor,
    duration: displayDuration,
    showCloseIcon: showCloseIcon,
    closeIconColor: foregroundColor,
  ));
}