Toast class
轻提示
在页面中间弹出提示,用于消息通知、加载提示、操作结果提示等场景。
使用时需在Material方法中传入builder参数。 dart ''' Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Toast', home: MyHomePage(title: 'Flutter Toast'), builder: Toast.init(), ); } '''
Constructors
- Toast.new()
-
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
key
→ GlobalKey<
ToastContainerState> ? -
no setter
-
loadingMessageKey
→ GlobalKey<
MessageAndIndicatorState> ? -
no setter
-
messageKey
→ GlobalKey<
MessageAndIndicatorState> ? -
no setter
- overlayEntry ↔ ToastOverlayEntry?
-
getter/setter pair
-
progressKey
→ GlobalKey<
ToastProgressState> ? -
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- theme → ToastThemeData
-
no setter
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 Methods
-
addStatusCallback(
ToastStatusCallback callback) → void - 添加加载状态回调
-
dismiss(
{bool animation = true}) → Future< void> - 关闭Toast
-
error(
String message, {BuildContext? context, Widget? errorIcon, TextStyle? textStyle, Color? backgroundColor, Color? foregroundColor, EdgeInsetsGeometry? padding, BorderRadius? borderRadius, VisualDensity? visualDensity, TextAlign? textAlign, Color? maskColor, double? verticalGap, double? indicatorSize, ToastPosition? position, Duration? displayDuration, ToastAnimationBuilder? animationBuilder, bool? dismissOnTap, bool? isInteractive}) → Future< void> - 显示失败状态
-
init(
{TransitionBuilder? builder}) → TransitionBuilder - 初始化 Toast
-
loading(
{BuildContext? context, String? message, Widget? indicator, TextStyle? textStyle, Color? backgroundColor, Color? foregroundColor, EdgeInsetsGeometry? padding, BorderRadius? borderRadius, VisualDensity? visualDensity, TextAlign? textAlign, Color? maskColor, double? verticalGap, double? indicatorSize, double? indicatorWidth, ToastPosition? position, Duration? animationDuration, ToastAnimationBuilder? animationBuilder, bool? dismissOnTap = true, bool? isInteractive = false, bool updateOnly = true}) → Future< void> - 显示加载状态
-
removeAllCallbacks(
) → void - 删除所有加载状态回调
-
removeCallback(
ToastStatusCallback callback) → void - 删除单个加载状态回调
-
show(
String message, {BuildContext? context, TextStyle? textStyle, Color? backgroundColor, Color? foregroundColor, EdgeInsetsGeometry? padding, BorderRadius? borderRadius, TextAlign? textAlign, Color? maskColor, ToastPosition? position, Duration? displayDuration, ToastAnimationBuilder? animationBuilder, bool? dismissOnTap, bool? isInteractive}) → Future< void> - 文字提示
-
showInfo(
String message, {BuildContext? context, Widget? icon, TextStyle? textStyle, Color? backgroundColor, Color? foregroundColor, EdgeInsetsGeometry? padding, BorderRadius? borderRadius, VisualDensity? visualDensity, TextAlign? textAlign, Color? maskColor, double? verticalGap, double? indicatorSize, ToastPosition? position, Duration? displayDuration, ToastAnimationBuilder? animationBuilder, bool? dismissOnTap, bool? isInteractive}) → Future< void> - 显示信息
-
showProgress(
double value, {BuildContext? context, String? message, TextStyle? textStyle, Color? backgroundColor, Color? foregroundColor, EdgeInsetsGeometry? padding, BorderRadius? borderRadius, VisualDensity? visualDensity, TextAlign? textAlign, Color? maskColor, double? verticalGap, double? indicatorSize, double? indicatorWidth, ToastPosition? position, Duration? animationDuration, ToastAnimationBuilder? animationBuilder, bool? dismissOnTap, bool? isInteractive}) → Future< void> - 显示进度,值应在0.0-1.0之间。
-
success(
String message, {BuildContext? context, Widget? successIcon, TextStyle? textStyle, Color? backgroundColor, Color? foregroundColor, EdgeInsetsGeometry? padding, BorderRadius? borderRadius, VisualDensity? visualDensity, TextAlign? textAlign, Color? maskColor, double? verticalGap, double? indicatorSize, ToastPosition? position, Duration? displayDuration, ToastAnimationBuilder? animationBuilder, bool? dismissOnTap, bool? isInteractive}) → Future< void> - 显示成功状态