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 showSimpleNotificationOption.notification
corresponds to the default value of showNotificationOption.customNotification
corresponds to the default value of showCustomNotificationOption.text
corresponds to the default value of showTextOption.customText
corresponds to the default value of showCustomTextOption.loading
corresponds to the default value of showLoadingOption.customLoading
corresponds to the default value of showCustomLoadingOption.attached
corresponds to the default value of showAttachedWidgetOption.animation
corresponds to the default value of showAnimationWidgetOption.enhanced
corresponds to the default value of showEnhancedWidgetfinal
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 theCancelFunc
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 usetarget
ortargetContext
, not both.verticalOffset
is the vertical offset, and it depends onpreferDirection
. It applies in different directions based on the direction.horizontalOffset
is the horizontal offset and depends onpreferDirection
. 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 toshowAnimationWidget.wrapAnimation
. Default value is null.wrapToastAnimation
Please refer toshowAnimationWidget.wrapToastAnimation
. Default value isattachedAnimation
.animationDuration
Please refer toshowAnimationWidget.animationDuration
.animationReverseDuration
Please refer toshowAnimationWidget.animationReverseDuration
.duration
Please refer toshowEnhancedWidget.duration
.ignoreContentClick
Please refer toshowEnhancedWidget.ignoreContentClick
.onlyOne
Please refer toshowEnhancedWidget.onlyOne
.allowClick
Please refer toshowEnhancedWidget.allowClick
.onClose
Please refer toshowEnhancedWidget.onClose
.enableKeyboardSafeArea
Please refer toshowEnhancedWidget.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
- SeeshowAnimationWidget.wrapAnimation
, default value isloadingAnimation
.wrapToastAnimation
- SeeshowAnimationWidget.wrapToastAnimation
, default value is null.animationDuration
- SeeshowAnimationWidget.animationDuration
.animationReverseDuration
- SeeshowAnimationWidget.animationReverseDuration
.ignoreContentClick
- SeeshowEnhancedWidget.ignoreContentClick
.duration
- SeeshowEnhancedWidget.duration
.allowClick
- SeeshowEnhancedWidget.allowClick
.clickClose
- SeeshowEnhancedWidget.clickClose
.crossPage
- SeeshowEnhancedWidget.crossPage
.backgroundColor
- SeeshowEnhancedWidget.backgroundColor
.onClose
- SeeshowEnhancedWidget.onClose
.backButtonBehavior
- SeeshowEnhancedWidget.backButtonBehavior
.enableKeyboardSafeArea
- SeeshowEnhancedWidget.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
- SeeshowAnimationWidget.wrapAnimation
, default value is null.wrapToastAnimation
- SeeshowAnimationWidget.wrapToastAnimation
, default value isnotificationAnimation
.animationDuration
- SeeshowAnimationWidget.animationDuration
.animationReverseDuration
- SeeshowAnimationWidget.animationReverseDuration
.duration
- SeeshowEnhancedWidget.duration
.onlyOne
- SeeshowEnhancedWidget.onlyOne
.crossPage
- SeeshowEnhancedWidget.crossPage
.onClose
- SeeshowEnhancedWidget.onClose
.backButtonBehavior
- SeeshowEnhancedWidget.backButtonBehavior
.enableKeyboardSafeArea
- SeeshowEnhancedWidget.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
- SeeshowAnimationWidget.wrapAnimation
, default value is null.wrapToastAnimation
- SeeshowAnimationWidget.wrapToastAnimation
, default value istextAnimation
.animationDuration
- SeeshowAnimationWidget.animationDuration
.animationReverseDuration
- SeeshowAnimationWidget.animationReverseDuration
.ignoreContentClick
- SeeshowEnhancedWidget.ignoreContentClick
.duration
- SeeshowEnhancedWidget.duration
.onlyOne
- SeeshowEnhancedWidget.onlyOne
.clickClose
- SeeshowEnhancedWidget.clickClose
.crossPage
- SeeshowEnhancedWidget.crossPage
.backgroundColor
- SeeshowEnhancedWidget.backgroundColor
.onClose
- SeeshowEnhancedWidget.onClose
.backButtonBehavior
- SeeshowEnhancedWidget.backButtonBehavior
.enableKeyboardSafeArea
- SeeshowEnhancedWidget.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
- SeeshowAnimationWidget.wrapAnimation
, default value isloadingAnimation
.wrapToastAnimation
- SeeshowAnimationWidget.wrapToastAnimation
, default value is null.animationDuration
- SeeshowAnimationWidget.animationDuration
.animationReverseDuration
- SeeshowAnimationWidget.animationReverseDuration
.duration
- SeeshowEnhancedWidget.duration
.allowClick
- SeeshowEnhancedWidget.allowClick
.clickClose
- SeeshowEnhancedWidget.clickClose
.crossPage
- SeeshowEnhancedWidget.crossPage
.backgroundColor
- SeeshowEnhancedWidget.backgroundColor
.onClose
- SeeshowEnhancedWidget.onClose
.backButtonBehavior
- SeeshowEnhancedWidget.backButtonBehavior
.enableKeyboardSafeArea
- SeeshowEnhancedWidget.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
- SeeshowAnimationWidget.wrapAnimation
, default value is null.wrapToastAnimation
- SeeshowAnimationWidget.wrapToastAnimation
, default value isnotificationAnimation
.animationDuration
- SeeshowAnimationWidget.animationDuration
.animationReverseDuration
- SeeshowAnimationWidget.animationReverseDuration
.duration
- SeeshowEnhancedWidget.duration
.onlyOne
- SeeshowEnhancedWidget.onlyOne
.crossPage
- SeeshowEnhancedWidget.crossPage
.onClose
- SeeshowEnhancedWidget.onClose
.backButtonBehavior
- SeeshowEnhancedWidget.backButtonBehavior
.backgroundColor
- Defaults to Theme.of(context).cardColor.borderRadius
- Defaults to ThemeData.cardTheme.shape.enableKeyboardSafeArea
- SeeshowEnhancedWidget.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
- SeeshowAnimationWidget.wrapAnimation
, default value is null.wrapToastAnimation
- SeeshowAnimationWidget.wrapToastAnimation
, default value isnotificationAnimation
.animationDuration
- SeeshowAnimationWidget.animationDuration
.animationReverseDuration
- SeeshowAnimationWidget.animationReverseDuration
.duration
- SeeshowEnhancedWidget.duration
.crossPage
- SeeshowEnhancedWidget.crossPage
.onlyOne
- SeeshowEnhancedWidget.onlyOne
.onClose
- SeeshowEnhancedWidget.onClose
.backButtonBehavior
- SeeshowEnhancedWidget.backButtonBehavior
.backgroundColor
- Defaults to Theme.of(context).cardColor.borderRadius
- Defaults to ThemeData.cardTheme.shape.enableKeyboardSafeArea
- SeeshowEnhancedWidget.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
- SeeshowAnimationWidget.wrapAnimation
, default value is null.wrapToastAnimation
- SeeshowAnimationWidget.wrapToastAnimation
, default value istextAnimation
.animationDuration
- SeeshowAnimationWidget.animationDuration
.animationReverseDuration
- SeeshowAnimationWidget.animationReverseDuration
.backgroundColor
- SeeshowEnhancedWidget.backgroundColor
.duration
- SeeshowEnhancedWidget.duration
.onlyOne
- SeeshowEnhancedWidget.onlyOne
.clickClose
- SeeshowEnhancedWidget.clickClose
.crossPage
- SeeshowEnhancedWidget.crossPage
.onClose
- SeeshowEnhancedWidget.onClose
.backButtonBehavior
- SeeshowEnhancedWidget.backButtonBehavior
.enableKeyboardSafeArea
- SeeshowEnhancedWidget.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