snackBar static method

void snackBar({
  1. Key? key,
  2. required Widget content,
  3. Color? backgroundColor,
  4. double? elevation,
  5. EdgeInsetsGeometry? margin,
  6. EdgeInsetsGeometry? padding,
  7. double? width,
  8. ShapeBorder? shape,
  9. SnackBarBehavior? behavior,
  10. SnackBarAction? action,
  11. Duration? duration,
  12. Animation<double>? animation,
  13. VoidCallback? onVisible,
  14. DismissDirection? dismissDirection,
  15. Clip? clipBehavior,
})

Display the SnackBar

Implementation

static void snackBar({
  Key? key,
  required Widget content,
  Color? backgroundColor,
  double? elevation,
  EdgeInsetsGeometry? margin,
  EdgeInsetsGeometry? padding,
  double? width,
  ShapeBorder? shape,
  SnackBarBehavior? behavior,
  SnackBarAction? action,
  Duration? duration,
  Animation<double>? animation,
  VoidCallback? onVisible,
  DismissDirection? dismissDirection,
  Clip? clipBehavior,
}) {
  final state = ScaffoldMessenger.maybeOf(context!);
  state?.showSnackBar(
    SnackBar(
      key: key,
      content: content,
      backgroundColor: backgroundColor,
      elevation: elevation,
      margin: margin,
      padding: padding,
      width: width,
      shape: shape,
      behavior: behavior,
      action: action,
      duration: duration ?? const Duration(milliseconds: 4000),
      animation: animation,
      onVisible: onVisible,
      dismissDirection: dismissDirection ?? DismissDirection.down,
      clipBehavior: clipBehavior ?? Clip.hardEdge,
    ),
  );
}