show method
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(),
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,
);
},
);
}