showAnimationWidget static method
- required ToastBuilder toastBuilder,
- required Duration animationDuration,
- Duration? animationReverseDuration = nilDuration,
- WrapAnimation? wrapAnimation = nilWrapAnimation,
- WrapAnimation? wrapToastAnimation = nilWrapAnimation,
- BackButtonBehavior? backButtonBehavior = nilBackButtonBehavior,
- Object crossPage = nil,
- Object allowClick = nil,
- Object clickClose = nil,
- Object ignoreContentClick = nil,
- Object onlyOne = nil,
- Object enableKeyboardSafeArea = nil,
- Color backgroundColor = nilColor,
- Duration? duration = nilDuration,
- VoidCallback? onClose = nilVoidCallback,
- UniqueKey? key,
- String? groupKey,
Displays a Toast that uses Animation. For usage, refer to: BotToast.showCustomNotification BotToast.showCustomText BotToast.showCustomLoading BotToast.showAttachedWidget
toastBuilder
is the builder function to generate the Widget to be displayed.
animationDuration
is the duration of the forward animation, which is equivalent to AnimationController.duration. It's recommended not to exceed duration
.
animationReverseDuration
is the duration of the reverse animation, which is equivalent to AnimationController.reverseDuration.
wrapAnimation
wraps the animation of the MainContent area and can be used for custom animations. If null, it indicates no animation is needed. Using this function does not necessarily require using animations; it can also perform additional widget wrapping.
wrapToastAnimation
wraps the animation of the ToastContent area and can be used for custom animations. If null, it indicates no animation is needed. Using this function does not necessarily require using animations; it can also perform additional widget wrapping.
key
Please refer to showEnhancedWidget.key
.
groupKey
Please refer to showEnhancedWidget.groupKey
.
crossPage
Please refer to showEnhancedWidget.crossPage
.
allowClick
Please refer to showEnhancedWidget.allowClick
.
clickClose
Please refer to showEnhancedWidget.clickClose
.
ignoreContentClick
Please refer to showEnhancedWidget.ignoreContentClick
.
onlyOne
Please refer to showEnhancedWidget.onlyOne
.
backgroundColor
Please refer to showEnhancedWidget.backgroundColor
.
duration
Please refer to showEnhancedWidget.duration
.
onClose
Please refer to showEnhancedWidget.onClose
.
backButtonBehavior
Please refer to showEnhancedWidget.backButtonBehavior
.
enableKeyboardSafeArea
Please refer to showEnhancedWidget.enableKeyboardSafeArea
.
显示使用了Animation的Toast 使用请看: BotToast.showCustomNotification BotToast.showCustomText BotToast.showCustomLoading BotToast.showAttachedWidget
toastBuilder
生成需要显示的Widget的builder函数
animationDuration
正向动画的持续时间,其含义等同于AnimationController.duration,值得注意的是建议不要超过duration
animationReverseDuration
反向动画的持续时间,其含义等同于AnimationController.reverseDuration
wrapAnimation
包装MainContent区域的动画,可用于自定义动画,如果为null则表示不需要动画,
使用这个函数不意味着一定要使用动画,可以额外做一些包装widget的处理
wrapToastAnimation
包装ToastContent区域的动画,可用于自定义动画,如果为null则表示不需要动画,
使用这个函数不意味着一定要使用动画,可以额外做一些包装widget的处理
key
请看showEnhancedWidget.key
groupKey
请看showEnhancedWidget.groupKey
crossPage
请看showEnhancedWidget.crossPage
allowClick
请看showEnhancedWidget.allowClick
clickClose
请看showEnhancedWidget.clickClose
ignoreContentClick
请看showEnhancedWidget.ignoreContentClick
onlyOne
请看showEnhancedWidget.onlyOne
backgroundColor
请看showEnhancedWidget.backgroundColor
duration
请看showEnhancedWidget.duration
onClose
请看showEnhancedWidget.onClose
backButtonBehavior
请看showEnhancedWidget.backButtonBehavior
enableKeyboardSafeArea
请看showEnhancedWidget.enableKeyboardSafeArea
Implementation
static CancelFunc showAnimationWidget({
required ToastBuilder toastBuilder,
required Duration animationDuration,
Duration? animationReverseDuration = nilDuration,
WrapAnimation? wrapAnimation = nilWrapAnimation,
WrapAnimation? wrapToastAnimation = nilWrapAnimation,
BackButtonBehavior? backButtonBehavior = nilBackButtonBehavior,
/*bool*/ Object crossPage = nil,
/*bool*/ Object allowClick = nil,
/*bool*/ Object clickClose = nil,
/*bool*/ Object ignoreContentClick = nil,
/*bool*/ Object onlyOne = nil,
/*bool*/ Object enableKeyboardSafeArea = nil,
Color backgroundColor = nilColor,
Duration? duration = nilDuration,
VoidCallback? onClose = nilVoidCallback,
UniqueKey? key,
String? groupKey,
}) {
var o = defaultOption.animation;
animationReverseDuration = returnFirstIfNotNil(animationReverseDuration, o.animationReverseDuration);
wrapAnimation = returnFirstIfNotNil(wrapAnimation, o.wrapAnimation);
wrapToastAnimation = returnFirstIfNotNil(wrapToastAnimation, o.wrapToastAnimation);
backButtonBehavior = returnFirstIfNotNil(backButtonBehavior, o.backButtonBehavior);
crossPage = returnFirstIfNotNil(crossPage, o.crossPage);
allowClick = returnFirstIfNotNil(allowClick, o.allowClick);
clickClose = returnFirstIfNotNil(clickClose, o.clickClose);
ignoreContentClick = returnFirstIfNotNil(ignoreContentClick, o.ignoreContentClick);
onlyOne = returnFirstIfNotNil(onlyOne, o.onlyOne);
enableKeyboardSafeArea = returnFirstIfNotNil(enableKeyboardSafeArea, o.enableKeyboardSafeArea);
backgroundColor = returnFirstIfNotNil(backgroundColor, o.backgroundColor);
duration = returnFirstIfNotNil(duration, o.duration);
onClose = returnFirstIfNotNil(onClose, o.onClose);
assert(isNilOr<bool>([enableKeyboardSafeArea, onlyOne, clickClose, allowClick, ignoreContentClick, crossPage]), 'Must be of bool type');
AnimationController? controller = _createAnimationController(animationDuration, reverseDuration: animationReverseDuration);
return showEnhancedWidget(
allowClick: allowClick,
clickClose: clickClose,
groupKey: groupKey,
key: key,
crossPage: crossPage,
onClose: onClose,
onlyOne: onlyOne,
enableKeyboardSafeArea: enableKeyboardSafeArea,
backButtonBehavior: backButtonBehavior,
backgroundColor: backgroundColor,
ignoreContentClick: ignoreContentClick,
closeFunc: () async {
await controller?.reverse();
},
duration: duration,
warpWidget: (cancel, child) => ProxyInitState(
initStateCallback: () {
assert(!controller!.isAnimating);
controller!.forward();
},
child: ProxyDispose(
disposeCallback: () {
controller!.dispose();
controller = null;
},
child: wrapAnimation != null ? wrapAnimation(controller!, cancel, child) : child),
),
toastBuilder: (cancelFunc) =>
wrapToastAnimation != null ? wrapToastAnimation(controller!, cancelFunc, toastBuilder(cancelFunc)) : toastBuilder(cancelFunc));
}