showNotification static method
- ToastBuilder? leading = nilToastBuilder,
- ToastBuilder? title = nilToastBuilder,
- ToastBuilder? subtitle = nilToastBuilder,
- ToastBuilder? trailing = nilToastBuilder,
- WrapAnimation? wrapAnimation = nilWrapAnimation,
- WrapAnimation? wrapToastAnimation = nilWrapAnimation,
- GestureTapCallback? onTap = nilVoidCallback,
- Color? backgroundColor = nilColor,
- Object? borderRadius = nil,
- GestureLongPressCallback? onLongPress = nilVoidCallback,
- Alignment? align = nilAlignment,
- List<
DismissDirection> dismissDirections = nilDismissDirectionList, - BackButtonBehavior? backButtonBehavior = nilBackButtonBehavior,
- Duration? duration = nilDuration,
- Duration? animationDuration = nilDuration,
- Duration? animationReverseDuration = nilDuration,
- EdgeInsetsGeometry? contentPadding = nilEdgeInsets,
- EdgeInsetsGeometry? margin = nilEdgeInsets,
- VoidCallback? onClose = nilVoidCallback,
- Object enableKeyboardSafeArea = nil,
- Object enableSlideOff = nil,
- Object crossPage = nil,
- Object onlyOne = nil,
Display a standard notification Toast.
leading
, title
, subtitle
, trailing
, contentPadding
, margin
- Refer to ListTile.
enableSlideOff
- Whether sliding to dismiss is enabled.
align
- Alignment of the ToastContent area within the MainContent area.
dismissDirections
- Directions in which sliding to dismiss is allowed.
onTap
- Callback when the notification Toast is tapped.
onLongPress
- Callback when the notification Toast is long-pressed.
wrapAnimation
- See showAnimationWidget.wrapAnimation
, default value is null.
wrapToastAnimation
- See showAnimationWidget.wrapToastAnimation
, default value is notificationAnimation
.
animationDuration
- See showAnimationWidget.animationDuration
.
animationReverseDuration
- See showAnimationWidget.animationReverseDuration
.
duration
- See showEnhancedWidget.duration
.
onlyOne
- See showEnhancedWidget.onlyOne
.
crossPage
- See showEnhancedWidget.crossPage
.
onClose
- See showEnhancedWidget.onClose
.
backButtonBehavior
- See showEnhancedWidget.backButtonBehavior
.
backgroundColor
- Defaults to Theme.of(context).cardColor.
borderRadius
- Defaults to ThemeData.cardTheme.shape.
enableKeyboardSafeArea
- See showEnhancedWidget.enableKeyboardSafeArea
.
显示一个标准的通知Toast
leading
title
subtitle
trailing
contentPadding
_margin
请看ListTile
enableSlideOff
是否能滑动删除
align
ToastContent区域在MainContent区域的对齐
dismissDirections
能进行滑动关闭的方向
onTap
点击通知Toast的回调
onLongPress
长按通知Toast的回调
wrapAnimation
请看showAnimationWidget.wrapAnimation
,默认值为null
wrapToastAnimation
请看showAnimationWidget.wrapToastAnimation
,默认值为notificationAnimation
animationDuration
请看showAnimationWidget.animationDuration
animationReverseDuration
请看showAnimationWidget.animationReverseDuration
duration
请看showEnhancedWidget.duration
onlyOne
请看showEnhancedWidget.onlyOne
crossPage
请看showEnhancedWidget.crossPage
onClose
请看showEnhancedWidget.onClose
backButtonBehavior
请看showEnhancedWidget.backButtonBehavior
backgroundColor
defaults to Theme.of(context).cardColor
borderRadius
defaults to ThemeData.cardTheme.shape
enableKeyboardSafeArea
请看showEnhancedWidget.enableKeyboardSafeArea
Implementation
static CancelFunc showNotification(
{ToastBuilder? leading = nilToastBuilder,
ToastBuilder? title = nilToastBuilder,
ToastBuilder? subtitle = nilToastBuilder,
ToastBuilder? trailing = nilToastBuilder,
WrapAnimation? wrapAnimation = nilWrapAnimation,
WrapAnimation? wrapToastAnimation = nilWrapAnimation,
GestureTapCallback? onTap = nilVoidCallback,
Color? backgroundColor = nilColor,
/*double*/ Object? borderRadius = nil,
GestureLongPressCallback? onLongPress = nilVoidCallback,
Alignment? align = nilAlignment,
List<DismissDirection> dismissDirections = nilDismissDirectionList,
BackButtonBehavior? backButtonBehavior = nilBackButtonBehavior,
Duration? duration = nilDuration,
Duration? animationDuration = nilDuration,
Duration? animationReverseDuration = nilDuration,
EdgeInsetsGeometry? contentPadding = nilEdgeInsets,
EdgeInsetsGeometry? margin = nilEdgeInsets,
VoidCallback? onClose = nilVoidCallback,
/*bool*/ Object enableKeyboardSafeArea = nil,
/*bool*/ Object enableSlideOff = nil,
/*bool*/ Object crossPage = nil,
/*bool*/ Object onlyOne = nil}) {
var o = defaultOption.notification;
leading = returnFirstIfNotNil(leading, o.leading);
title = returnFirstIfNotNil(title, o.title);
subtitle = returnFirstIfNotNil(subtitle, o.subtitle);
trailing = returnFirstIfNotNil(trailing, o.trailing);
wrapAnimation = returnFirstIfNotNil(wrapAnimation, o.wrapAnimation);
wrapToastAnimation = returnFirstIfNotNil(wrapToastAnimation, o.wrapToastAnimation);
onTap = returnFirstIfNotNil(onTap, o.onTap);
backgroundColor = returnFirstIfNotNil(backgroundColor, o.backgroundColor);
onLongPress = returnFirstIfNotNil(onLongPress, o.onLongPress);
align = returnFirstIfNotNil(align, o.align);
dismissDirections = returnFirstIfNotNil(dismissDirections, o.dismissDirections);
backButtonBehavior = returnFirstIfNotNil(backButtonBehavior, o.backButtonBehavior);
duration = returnFirstIfNotNil(duration, o.duration);
animationDuration = returnFirstIfNotNil(animationDuration, o.animationDuration);
animationReverseDuration = returnFirstIfNotNil(animationReverseDuration, o.animationReverseDuration);
contentPadding = returnFirstIfNotNil(contentPadding, o.contentPadding);
margin = returnFirstIfNotNil(margin, o.contentPadding);
onClose = returnFirstIfNotNil(onClose, o.onClose);
enableKeyboardSafeArea = returnFirstIfNotNil(enableKeyboardSafeArea, o.enableKeyboardSafeArea);
enableSlideOff = returnFirstIfNotNil(enableSlideOff, o.enableSlideOff);
crossPage = returnFirstIfNotNil(crossPage, o.crossPage);
onlyOne = returnFirstIfNotNil(onlyOne, o.onlyOne);
final borderRadiusV = returnFirstIfNotNilAndCast<double?>(borderRadius, o.borderRadius);
assert(isNilOr<bool>([enableKeyboardSafeArea, enableSlideOff, crossPage, onlyOne]), 'Must be of bool type');
assert(isNilOr<double>([borderRadiusV]), 'Must be of double type');
return showCustomNotification(
wrapAnimation: wrapAnimation,
wrapToastAnimation: wrapToastAnimation,
align: align,
dismissDirections: dismissDirections,
enableSlideOff: enableSlideOff,
enableKeyboardSafeArea: enableKeyboardSafeArea,
onlyOne: onlyOne,
backButtonBehavior: backButtonBehavior,
crossPage: crossPage,
onClose: onClose,
duration: duration,
animationDuration: animationDuration,
animationReverseDuration: animationReverseDuration,
toastBuilder: (cancel) {
return Card(
margin: margin,
color: backgroundColor,
shape: borderRadiusV == null
? null
: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(borderRadiusV),
),
child: ListTile(
onTap: onTap,
onLongPress: onLongPress,
contentPadding: contentPadding,
leading: leading?.call(cancel),
title: title?.call(cancel),
subtitle: subtitle?.call(cancel),
trailing: trailing?.call(cancel)),
);
});
}