showSnack method

void showSnack({
  1. String? message,
  2. Color? textColor,
  3. Color? actionTextColor,
  4. Color? acitonBackgroundColor,
  5. Color? actionDisabledTextColor,
  6. Color? actionDisabledBackgroundColor,
  7. String? actionLabel,
  8. void onAction()?,
  9. Widget? content,
  10. Color? backgroundColor,
  11. double? elevation,
  12. EdgeInsetsGeometry? margin,
  13. EdgeInsetsGeometry? padding,
  14. double? width,
  15. ShapeBorder? shape,
  16. HitTestBehavior? hitTestBehavior,
  17. SnackBarBehavior? behavior,
  18. SnackBarAction? action,
  19. double? actionOverflowThreshold,
  20. bool? showCloseIcon,
  21. Color? closeIconColor,
  22. Duration duration = _snackBarDisplayDuration,
  23. Animation<double>? animation,
  24. void onVisible()?,
  25. DismissDirection dismissDirection = DismissDirection.down,
  26. Clip clipBehavior = Clip.hardEdge,
})

Implementation

void showSnack({
  String? message,
  Color? textColor,
  Color? actionTextColor,
  Color? acitonBackgroundColor,
  Color? actionDisabledTextColor,
  Color? actionDisabledBackgroundColor,
  String? actionLabel,
  void Function()? onAction,
  Widget? content,
  Color? backgroundColor,
  double? elevation,
  EdgeInsetsGeometry? margin,
  EdgeInsetsGeometry? padding,
  double? width,
  ShapeBorder? shape,
  HitTestBehavior? hitTestBehavior,
  SnackBarBehavior? behavior,
  SnackBarAction? action,
  double? actionOverflowThreshold,
  bool? showCloseIcon,
  Color? closeIconColor,
  Duration duration = _snackBarDisplayDuration,
  Animation<double>? animation,
  void Function()? onVisible,
  DismissDirection dismissDirection = DismissDirection.down,
  Clip clipBehavior = Clip.hardEdge,
}) {
  assert(message != null || content != null);

  SnackBarAction? ac = action;
  if (ac == null && actionLabel != null && onAction != null) {
    ac = SnackBarAction(
      label: actionLabel,
      onPressed: onAction,
      textColor: actionTextColor,
      backgroundColor: acitonBackgroundColor,
      disabledTextColor: actionDisabledTextColor,
      disabledBackgroundColor: actionDisabledBackgroundColor,
    );
  }

  SnackBar snackBar = SnackBar(
    content: content ?? message!.text(color: textColor),
    backgroundColor: backgroundColor,
    elevation: elevation,
    margin: margin,
    padding: padding,
    width: width,
    shape: shape,
    hitTestBehavior: hitTestBehavior,
    behavior: behavior,
    action: ac,
    actionOverflowThreshold: actionOverflowThreshold,
    showCloseIcon: showCloseIcon,
    closeIconColor: closeIconColor,
    duration: duration,
    animation: animation,
    onVisible: onVisible,
    dismissDirection: dismissDirection,
    clipBehavior: clipBehavior,
  );
  ScaffoldMessenger.of(context).showSnackBar(snackBar);
}