showCustomNotification static method
- required ToastBuilder toastBuilder,
- WrapAnimation? wrapAnimation = nilWrapAnimation,
- WrapAnimation? wrapToastAnimation = nilWrapAnimation,
- Alignment? align = nilAlignment,
- List<
DismissDirection> dismissDirections = nilDismissDirectionList, - Duration? duration = nilDuration,
- Duration? animationDuration = nilDuration,
- Duration? animationReverseDuration = nilDuration,
- VoidCallback? onClose = nilVoidCallback,
- BackButtonBehavior? backButtonBehavior = nilBackButtonBehavior,
- Object enableKeyboardSafeArea = nil,
- Object enableSlideOff = nil,
- Object crossPage = nil,
- Object onlyOne = nil,
- Object useSafeArea = nil,
Display a custom notification Toast.
toastBuilder - Builder function to generate the Widget to be displayed.
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.
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.
enableKeyboardSafeArea - See showEnhancedWidget.enableKeyboardSafeArea.
显示一个自定义的通知Toast
toastBuilder 生成需要显示的Widget的builder函数
enableSlideOff 是否能滑动删除
align ToastContent区域在MainContent区域的对齐
dismissDirections 能进行滑动关闭的方向
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
enableKeyboardSafeArea 请看showEnhancedWidget.enableKeyboardSafeArea
Implementation
static CancelFunc showCustomNotification(
{required ToastBuilder toastBuilder,
WrapAnimation? wrapAnimation = nilWrapAnimation,
WrapAnimation? wrapToastAnimation = nilWrapAnimation,
Alignment? align = nilAlignment,
List<DismissDirection> dismissDirections = nilDismissDirectionList,
Duration? duration = nilDuration,
Duration? animationDuration = nilDuration,
Duration? animationReverseDuration = nilDuration,
VoidCallback? onClose = nilVoidCallback,
BackButtonBehavior? backButtonBehavior = nilBackButtonBehavior,
/*bool*/ Object enableKeyboardSafeArea = nil,
/*bool*/ Object enableSlideOff = nil,
/*bool*/ Object crossPage = nil,
/*bool*/ Object onlyOne = nil,
/*bool*/ Object useSafeArea = nil}) {
var o = defaultOption.customNotification;
wrapAnimation = returnFirstIfNotNil(wrapAnimation, o.wrapAnimation);
wrapToastAnimation = returnFirstIfNotNil(wrapToastAnimation, o.wrapToastAnimation);
align = returnFirstIfNotNil(align, o.align);
dismissDirections = returnFirstIfNotNil(dismissDirections, o.dismissDirections);
duration = returnFirstIfNotNil(duration, o.duration);
animationReverseDuration = returnFirstIfNotNil(animationReverseDuration, o.animationReverseDuration);
onClose = returnFirstIfNotNil(onClose, o.onClose);
backButtonBehavior = returnFirstIfNotNil(backButtonBehavior, o.backButtonBehavior);
enableKeyboardSafeArea = returnFirstIfNotNil(enableKeyboardSafeArea, o.enableKeyboardSafeArea);
crossPage = returnFirstIfNotNil(crossPage, o.crossPage);
onlyOne = returnFirstIfNotNil(onlyOne, o.onlyOne);
useSafeArea = returnFirstIfNotNil(useSafeArea, o.useSafeArea);
enableSlideOff = returnFirstIfNotNil(enableSlideOff, o.enableSlideOff);
final animationDurationV = returnFirstIfNotNilAndCast<Duration?>(animationDuration, o.animationDuration);
assert(isNilOr<bool>([enableKeyboardSafeArea, enableSlideOff, crossPage, onlyOne, useSafeArea]), 'Must be of bool type');
return showAnimationWidget(
crossPage: crossPage,
allowClick: true,
clickClose: false,
ignoreContentClick: false,
enableKeyboardSafeArea: enableKeyboardSafeArea,
onlyOne: onlyOne,
onClose: onClose,
duration: duration,
backButtonBehavior: backButtonBehavior,
animationDuration: animationDurationV ?? o.animationDuration,
animationReverseDuration: animationReverseDuration,
wrapAnimation: wrapAnimation,
wrapToastAnimation: (controller, cancel, child) {
if (wrapToastAnimation != null) {
child = wrapToastAnimation(controller, cancel, child);
}
if (align != null) {
child = Align(alignment: align, child: child);
}
return useSafeArea == true ? SafeArea(child: child) : child;
},
toastBuilder: (cancelFunc) => NotificationToast(
child: toastBuilder(cancelFunc), dismissDirections: dismissDirections, slideOffFunc: enableSlideOff == true ? cancelFunc : null),
groupKey: notificationKey);
}