BotToast class

When generating widgets using the ToastBuilder method, please ensure that the generated widget's background does not absorb click events. For example, Scaffold and Material widgets will by default occupy the entire parent space and absorb events (even if they are transparent). You can refer to the material.dart -> _RenderInkFeatures class -> hitTestSelf method for specific examples. If you must generate such widgets, consider using IgnorePointer. Failure to follow this rule may result in the malfunction of certain features, such as the allowClick feature.

ToastBuilder方法生成widget时,请确保生成的Widget背景不会吸收点击事件 例如Scaffold,Material都会默认占满整个父空间, 并且会吸收事件(就算透明也是这种情况),具体例子可看material.dart->_RenderInkFeatures class->hitTestSelf method 如果真的要生成,可以考虑使用IgnorePointer. 如果没有遵守规则,将会时某些功能失效例如allowClick功能就会失效

Constructors

BotToast()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

cacheCancelFunc Map<String, List<CancelFunc>>
final
defaultOption → Option
Global default options Once these default options are modified, they will take effect globally. Option.simpleNotification corresponds to the default value of showSimpleNotification Option.notification corresponds to the default value of showNotification Option.customNotification corresponds to the default value of showCustomNotification Option.text corresponds to the default value of showText Option.customText corresponds to the default value of showCustomText Option.loading corresponds to the default value of showLoading Option.customLoading corresponds to the default value of showCustomLoading Option.attached corresponds to the default value of showAttachedWidget Option.animation corresponds to the default value of showAnimationWidget Option.enhanced corresponds to the default value of showEnhancedWidget
final

Static Methods

cleanAll() → void
closeAllLoading() → void
This method is generally used in dispose to ensure that the Toast is closed properly. It prevents scenarios where the developer forgets to close it manually or if there's an API request error that prevents the CancelFunc from executing. This ensures that the user can interact with the app normally. 此方法一般使用在dispose里面,防止因为开发人员没有主动去关闭,或者是请求api时的出现异常导致CancelFunc方法没有执行到等等,导致用户点击不了app
remove(UniqueKey key, [String? groupKey]) → void
removeAll([String? groupKey]) → void
showAnimationWidget({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}) CancelFunc
Displays a Toast that uses Animation. For usage, refer to: BotToast.showCustomNotification BotToast.showCustomText BotToast.showCustomLoading BotToast.showAttachedWidget
showAttachedWidget({required ToastBuilder attachedBuilder, BuildContext? targetContext, Offset? target, WrapAnimation? wrapAnimation = nilWrapAnimation, WrapAnimation? wrapToastAnimation = nilWrapAnimation, Color backgroundColor = nilColor, Object verticalOffset = nil, Object horizontalOffset = nil, Duration? duration = nilDuration, Duration? animationDuration = nilDuration, Duration? animationReverseDuration = nilDuration, PreferDirection? preferDirection = nilPreferDirection, VoidCallback? onClose = nilVoidCallback, Object ignoreContentClick = nil, Object onlyOne = nil, Object allowClick = nil, Object enableKeyboardSafeArea = nil, Object enableSafeArea = nil}) CancelFunc
Displays a positioned Toast. This method can display the Toast around a given Widget (usually a Button) or at a specific offset. attachedBuilder is the builder function to generate the Widget to be displayed. targetContext is the target Widget (usually a button). It's usually wrapped in a Builder to obtain the BuildContext. target is the target Offset. The offset is calculated relative to the top-left corner of the screen. You can either use target or targetContext, not both. verticalOffset is the vertical offset, and it depends on preferDirection. It applies in different directions based on the direction. horizontalOffset is the horizontal offset and depends on preferDirection. It applies in different directions based on the direction. preferDirection is the preferred direction. If space allows, it will prefer to display in that direction. enableSafeArea If true, the toast ensures it doesn't display over the app status bar (it means it's safe); false otherwise. wrapAnimation Please refer to showAnimationWidget.wrapAnimation. Default value is null. wrapToastAnimation Please refer to showAnimationWidget.wrapToastAnimation. Default value is attachedAnimation. animationDuration Please refer to showAnimationWidget.animationDuration. animationReverseDuration Please refer to showAnimationWidget.animationReverseDuration. duration Please refer to showEnhancedWidget.duration. ignoreContentClick Please refer to showEnhancedWidget.ignoreContentClick. onlyOne Please refer to showEnhancedWidget.onlyOne. allowClick Please refer to showEnhancedWidget.allowClick. onClose Please refer to showEnhancedWidget.onClose. enableKeyboardSafeArea Please refer to showEnhancedWidget.enableKeyboardSafeArea.
showCustomLoading({required ToastBuilder toastBuilder, WrapAnimation? wrapAnimation = nilWrapAnimation, WrapAnimation? wrapToastAnimation = nilWrapAnimation, Alignment? align = nilAlignment, BackButtonBehavior? backButtonBehavior = nilBackButtonBehavior, Object clickClose = nil, Object allowClick = nil, Object ignoreContentClick = nil, Object crossPage = nil, Object enableKeyboardSafeArea = nil, VoidCallback? onClose = nilVoidCallback, Duration? duration = nilDuration, Duration? animationDuration = nilDuration, Duration? animationReverseDuration = nilDuration, Color backgroundColor = nilColor, Object useSafeArea = nil}) CancelFunc
Display a custom loading Toast. toastBuilder - Builder function to generate the widget to display. align - Alignment of the ToastContent area within the MainContent area. wrapAnimation - See showAnimationWidget.wrapAnimation, default value is loadingAnimation. wrapToastAnimation - See showAnimationWidget.wrapToastAnimation, default value is null. animationDuration - See showAnimationWidget.animationDuration. animationReverseDuration - See showAnimationWidget.animationReverseDuration. ignoreContentClick - See showEnhancedWidget.ignoreContentClick. duration - See showEnhancedWidget.duration. allowClick - See showEnhancedWidget.allowClick. clickClose - See showEnhancedWidget.clickClose. crossPage - See showEnhancedWidget.crossPage. backgroundColor - See showEnhancedWidget.backgroundColor. onClose - See showEnhancedWidget.onClose. backButtonBehavior - See showEnhancedWidget.backButtonBehavior. enableKeyboardSafeArea - See showEnhancedWidget.enableKeyboardSafeArea.
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, Object enableKeyboardSafeArea = nil, Object enableSlideOff = nil, Object crossPage = nil, Object onlyOne = nil, Object useSafeArea = nil}) CancelFunc
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.
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, Object enableKeyboardSafeArea = nil, Object crossPage = nil, Object clickClose = nil, Object ignoreContentClick = nil, Object onlyOne = nil, Object useSafeArea = nil}) CancelFunc
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.
showEnhancedWidget({required ToastBuilder toastBuilder, UniqueKey? key, String? groupKey, Object crossPage = nil, Object allowClick = nil, Object clickClose = nil, Object ignoreContentClick = nil, Object onlyOne = nil, Object enableKeyboardSafeArea = nil, BackButtonBehavior? backButtonBehavior = nilBackButtonBehavior, FutureFunc? closeFunc = nilFutureFunc, VoidCallback? onClose = nilVoidCallback, Color backgroundColor = nilColor, WrapWidget? warpWidget = nilWrapWidget, Duration? duration = nilDuration}) CancelFunc
Displays an enhanced Toast with many built-in features such as automatic timing closure, auto-closure on screen tap, and closure upon leaving the current Route. Core method, for detailed usage, refer to: BotToast.showAnimationWidget
showLoading({WrapAnimation? wrapAnimation = nilWrapAnimation, WrapAnimation? wrapToastAnimation = nilWrapAnimation, Alignment align = nilAlignment, BackButtonBehavior? backButtonBehavior = nilBackButtonBehavior, Object crossPage = nil, Object clickClose = nil, Object allowClick = nil, Object enableKeyboardSafeArea = nil, VoidCallback? onClose = nilVoidCallback, Duration? duration = nilDuration, Duration? animationDuration = nilDuration, Duration? animationReverseDuration = nilDuration, Color backgroundColor = nilColor}) CancelFunc
Display a standard loading Toast. align - Alignment of the ToastContent area within the MainContent area. wrapAnimation - See showAnimationWidget.wrapAnimation, default value is loadingAnimation. wrapToastAnimation - See showAnimationWidget.wrapToastAnimation, default value is null. animationDuration - See showAnimationWidget.animationDuration. animationReverseDuration - See showAnimationWidget.animationReverseDuration. duration - See showEnhancedWidget.duration. allowClick - See showEnhancedWidget.allowClick. clickClose - See showEnhancedWidget.clickClose. crossPage - See showEnhancedWidget.crossPage. backgroundColor - See showEnhancedWidget.backgroundColor. onClose - See showEnhancedWidget.onClose. backButtonBehavior - See showEnhancedWidget.backButtonBehavior. enableKeyboardSafeArea - See showEnhancedWidget.enableKeyboardSafeArea.
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, 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}) CancelFunc
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.
showSimpleNotification({required String title, Object? subTitle = nil, TextStyle? titleStyle = nilTextStyle, TextStyle? subTitleStyle = nilTextStyle, WrapAnimation? wrapAnimation = nilWrapAnimation, WrapAnimation? wrapToastAnimation = nilWrapAnimation, GestureTapCallback? onTap = nilVoidCallback, GestureLongPressCallback? onLongPress = nilVoidCallback, Color? backgroundColor = nilColor, Object? borderRadius = nilBackButtonBehavior, Alignment? align = nilAlignment, List<DismissDirection> dismissDirections = nilDismissDirectionList, Icon? closeIcon = nilIcon, Duration? duration = nilDuration, Duration? animationDuration = nilDuration, Duration? animationReverseDuration = nilDuration, BackButtonBehavior? backButtonBehavior = nilBackButtonBehavior, VoidCallback? onClose = nilVoidCallback, Object enableKeyboardSafeArea = nil, Object enableSlideOff = nil, Object hideCloseButton = nil, Object crossPage = nil, Object onlyOne = nil}) CancelFunc
Display a simple notification Toast. title - Title. subTitle - Subtitle. closeIcon - Icon for the close button. enableSlideOff - Whether sliding to dismiss is enabled. hideCloseButton - Whether to hide the close button. 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. crossPage - See showEnhancedWidget.crossPage. onlyOne - See showEnhancedWidget.onlyOne. 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.
showText({required String text, WrapAnimation? wrapAnimation = nilWrapAnimation, WrapAnimation? wrapToastAnimation = nilWrapAnimation, Color backgroundColor = nilColor, Color contentColor = nilColor, BorderRadiusGeometry borderRadius = nilBorderRadius, TextStyle textStyle = nilTextStyle, AlignmentGeometry? align = nilAlignment, EdgeInsetsGeometry contentPadding = nilEdgeInsets, Duration? duration = nilDuration, Duration? animationDuration = nilDuration, Duration? animationReverseDuration = nilDuration, BackButtonBehavior? backButtonBehavior = nilBackButtonBehavior, VoidCallback? onClose = nilVoidCallback, Object enableKeyboardSafeArea = nil, Object clickClose = nil, Object crossPage = nil, Object onlyOne = nil}) CancelFunc
Display a standard text Toast. text - The text to be displayed. contentColor - Background color of the ToastContent area. borderRadius - BorderRadius of the ToastContent area. textStyle - Text style. contentPadding - Padding of the ToastContent area. 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. backgroundColor - See showEnhancedWidget.backgroundColor. duration - See showEnhancedWidget.duration. onlyOne - See showEnhancedWidget.onlyOne. clickClose - See showEnhancedWidget.clickClose. crossPage - See showEnhancedWidget.crossPage. onClose - See showEnhancedWidget.onClose. backButtonBehavior - See showEnhancedWidget.backButtonBehavior. enableKeyboardSafeArea - See showEnhancedWidget.enableKeyboardSafeArea.
showWidget({required ToastBuilder toastBuilder, UniqueKey? key, String? groupKey}) CancelFunc
Displays a Widget on the screen that can persist across multiple pages. toastBuilder is the builder function to generate the Widget to be displayed. key represents a credential for this Toast. With this key, you can remove the Widget defined by the current key using remove. groupKey represents a group key, mainly used for removeAll and remove. CancelFunc is the close function, and actively calling it will close this Toast. This is a core method.

Constants

attachedKey → const String
defaultKey → const String
loadKey → const String
notificationKey → const String
textKey → const String