showCustomText static method

CancelFunc showCustomText({
  1. required ToastBuilder toastBuilder,
  2. WrapAnimation? wrapAnimation = nilWrapAnimation,
  3. WrapAnimation? wrapToastAnimation = nilWrapAnimation,
  4. AlignmentGeometry? align = nilAlignment,
  5. Color backgroundColor = nilColor,
  6. Duration? duration = nilDuration,
  7. Duration? animationDuration = nilDuration,
  8. Duration? animationReverseDuration = nilDuration,
  9. VoidCallback? onClose = nilVoidCallback,
  10. BackButtonBehavior? backButtonBehavior = nilBackButtonBehavior,
  11. Object enableKeyboardSafeArea = nil,
  12. Object crossPage = nil,
  13. Object clickClose = nil,
  14. Object ignoreContentClick = nil,
  15. Object onlyOne = nil,
  16. Object useSafeArea = nil,
})

Display a custom text Toast. toastBuilder - A builder function that generates the widget to be displayed. align - Alignment of the ToastContent area within the MainContent area. wrapAnimation - See showAnimationWidget.wrapAnimation, default value is null. wrapToastAnimation - See showAnimationWidget.wrapToastAnimation, default value is textAnimation. animationDuration - See showAnimationWidget.animationDuration. animationReverseDuration - See showAnimationWidget.animationReverseDuration. ignoreContentClick - See showEnhancedWidget.ignoreContentClick. duration - See showEnhancedWidget.duration. onlyOne - See showEnhancedWidget.onlyOne. clickClose - See showEnhancedWidget.clickClose. crossPage - See showEnhancedWidget.crossPage. backgroundColor - See showEnhancedWidget.backgroundColor. onClose - See showEnhancedWidget.onClose. backButtonBehavior - See showEnhancedWidget.backButtonBehavior. enableKeyboardSafeArea - See showEnhancedWidget.enableKeyboardSafeArea.

显示一个自定义的文本Toast toastBuilder 生成需要显示的Widget的builder函数 align ToastContent区域在MainContent区域的对齐 wrapAnimation 请看showAnimationWidget.wrapAnimation,默认值为null wrapToastAnimation 请看showAnimationWidget.wrapToastAnimation,默认值为textAnimation animationDuration 请看showAnimationWidget.animationDuration animationReverseDuration 请看showAnimationWidget.animationReverseDuration ignoreContentClick 请看showEnhancedWidget.ignoreContentClick duration 请看showEnhancedWidget.duration onlyOne 请看showEnhancedWidget.onlyOne clickClose 请看showEnhancedWidget.clickClose crossPage 请看showEnhancedWidget.crossPage backgroundColor 请看showEnhancedWidget.backgroundColor onClose 请看showEnhancedWidget.onClose backButtonBehavior 请看showEnhancedWidget.backButtonBehavior enableKeyboardSafeArea 请看showEnhancedWidget.enableKeyboardSafeArea

Implementation

static CancelFunc showCustomText({
  required ToastBuilder toastBuilder,
  WrapAnimation? wrapAnimation = nilWrapAnimation,
  WrapAnimation? wrapToastAnimation = nilWrapAnimation,
  AlignmentGeometry? align = nilAlignment,
  Color backgroundColor = nilColor,
  Duration? duration = nilDuration,
  Duration? animationDuration = nilDuration,
  Duration? animationReverseDuration = nilDuration,
  VoidCallback? onClose = nilVoidCallback,
  BackButtonBehavior? backButtonBehavior = nilBackButtonBehavior,
  /*bool*/ Object enableKeyboardSafeArea = nil,
  /*bool*/ Object crossPage = nil,
  /*bool*/ Object clickClose = nil,
  /*bool*/ Object ignoreContentClick = nil,
  /*bool*/ Object onlyOne = nil,
  /*bool*/ Object useSafeArea = nil,
}) {
  var o = defaultOption.customText;

  wrapAnimation = returnFirstIfNotNil(wrapAnimation, o.wrapAnimation);
  wrapToastAnimation = returnFirstIfNotNil(wrapToastAnimation, o.wrapToastAnimation);
  align = returnFirstIfNotNil(align, o.align);
  backgroundColor = returnFirstIfNotNil(backgroundColor, o.backgroundColor);
  duration = returnFirstIfNotNil(duration, o.duration);
  animationDuration = returnFirstIfNotNil(animationDuration, o.animationDuration);
  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);
  clickClose = returnFirstIfNotNil(clickClose, o.clickClose);
  ignoreContentClick = returnFirstIfNotNil(ignoreContentClick, o.ignoreContentClick);
  onlyOne = returnFirstIfNotNil(onlyOne, o.onlyOne);
  useSafeArea = returnFirstIfNotNil(useSafeArea, o.useSafeArea);

  assert(isNilOr<bool>([enableKeyboardSafeArea, clickClose, crossPage, onlyOne, ignoreContentClick, useSafeArea]), 'Must be of bool type');

  return showAnimationWidget(
      groupKey: textKey,
      clickClose: clickClose,
      allowClick: true,
      enableKeyboardSafeArea: enableKeyboardSafeArea,
      onlyOne: onlyOne,
      crossPage: crossPage,
      ignoreContentClick: ignoreContentClick,
      backgroundColor: backgroundColor,
      backButtonBehavior: backButtonBehavior,
      onClose: onClose,
      duration: duration,
      animationDuration: animationDuration ?? 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: toastBuilder);
}