show method

ToastificationItem show({
  1. BuildContext? context,
  2. OverlayState? overlayState,
  3. AlignmentGeometry? alignment,
  4. Duration? autoCloseDuration,
  5. Duration? animationDuration,
  6. ToastificationAnimationBuilder? animationBuilder,
  7. ToastificationType? type,
  8. ToastificationStyle? style,
  9. Widget? title,
  10. Widget? description,
  11. Widget? icon,
  12. Color? primaryColor,
  13. Color? backgroundColor,
  14. Color? foregroundColor,
  15. EdgeInsetsGeometry? padding,
  16. EdgeInsetsGeometry? margin,
  17. BorderRadiusGeometry? borderRadius,
  18. BorderSide? borderSide,
  19. List<BoxShadow>? boxShadow,
  20. TextDirection? direction,
  21. bool? showProgressBar,
  22. ProgressIndicatorThemeData? progressBarTheme,
  23. @Deprecated('IMPORTANT: The closeButtonShowType parameter is deprecated and will be removed in the next major version. Use the closeButton parameter instead.') CloseButtonShowType? closeButtonShowType,
  24. ToastCloseButton closeButton = const ToastCloseButton(),
  25. bool? closeOnClick,
  26. bool? dragToClose,
  27. bool? showIcon,
  28. DismissDirection? dismissDirection,
  29. bool? pauseOnHover,
  30. bool? applyBlurEffect,
  31. ToastificationCallbacks callbacks = const ToastificationCallbacks(),
})

shows a predefined toast widget base on the parameters

you can use this method to show a built-in toasts

the return value is a ToastificationItem that you can use to dismiss the notification or find the notification details by its id

example :

toastification.show(
  context: context, // optional if ToastificationWrapper is in widget tree
  alignment: Alignment.topRight,
  title: Text('Hello World'),
  description: Text('This is a notification'),
  type: ToastificationType.info,
  style: ToastificationStyle.flat,
  autoCloseDuration: Duration(seconds: 3),
);

TODO(payam): add close button icon parameter

Implementation

ToastificationItem show({
  BuildContext? context,
  OverlayState? overlayState,
  AlignmentGeometry? alignment,
  Duration? autoCloseDuration,
  Duration? animationDuration,
  ToastificationAnimationBuilder? animationBuilder,
  ToastificationType? type,
  ToastificationStyle? style,
  Widget? title,
  Widget? description,
  Widget? icon,
  Color? primaryColor,
  Color? backgroundColor,
  Color? foregroundColor,
  EdgeInsetsGeometry? padding,
  EdgeInsetsGeometry? margin,
  BorderRadiusGeometry? borderRadius,
  BorderSide? borderSide,
  List<BoxShadow>? boxShadow,
  TextDirection? direction,
  bool? showProgressBar,
  ProgressIndicatorThemeData? progressBarTheme,
  @Deprecated(
      'IMPORTANT: The closeButtonShowType parameter is deprecated and will be removed in the next major version. Use the closeButton parameter instead.')
  CloseButtonShowType? closeButtonShowType,
  ToastCloseButton closeButton = const ToastCloseButton(),
  bool? closeOnClick,
  bool? dragToClose,
  bool? showIcon,
  DismissDirection? dismissDirection,
  bool? pauseOnHover,
  bool? applyBlurEffect,
  ToastificationCallbacks callbacks = const ToastificationCallbacks(),
}) {
  // TODO: remove this variable when the deprecated parameter (closeButtonShowType) is removed
  var toastCloseButton = closeButton;
  if (closeButtonShowType != null &&
      closeButtonShowType != closeButton.showType) {
    toastCloseButton = closeButton.copyWith(showType: closeButtonShowType);
  }

  return showCustom(
    context: context,
    overlayState: overlayState,
    alignment: alignment,
    direction: direction,
    autoCloseDuration: autoCloseDuration,
    animationBuilder: animationBuilder,
    animationDuration: animationDuration,
    callbacks: callbacks,
    builder: (context, holder) {
      return BuiltInBuilder(
        item: holder,
        type: type,
        style: style,
        title: title,
        description: description,
        icon: icon,
        primaryColor: primaryColor,
        backgroundColor: backgroundColor,
        foregroundColor: foregroundColor,
        padding: padding,
        margin: margin,
        borderRadius: borderRadius,
        borderSide: borderSide,
        boxShadow: boxShadow,
        direction: direction,
        showIcon: showIcon,
        showProgressBar: showProgressBar,
        progressBarTheme: progressBarTheme,
        closeButton: toastCloseButton,
        closeOnClick: closeOnClick,
        dragToClose: dragToClose,
        dismissDirection: dismissDirection,
        pauseOnHover: pauseOnHover,
        applyBlurEffect: applyBlurEffect,
        callbacks: callbacks,
      );
    },
  );
}