Toast class

Constructors

Toast()
factory

Properties

globalAnimationConfig ToastAnimationConfig
Toast 全局动画配置
getter/setter pair
globalBuildToastQueueStyle BuildToastQueueStyle?
getter/setter pair
globalBuildToastStyle BuildToastStyle?
构建toast样式,外部自定义方式
getter/setter pair
globalPosition ToastPosition
显示位置
getter/setter pair
globalToastStyleConfig ToastStyleConfig
Toast 全局样式配置
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
intervalTime int
两次toast的间隔时间
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showTime int
toast显示时间 单位 毫秒
getter/setter pair

Methods

initBaseStyle({EdgeInsetsGeometry? globalToastMargin, EdgeInsetsGeometry? globalToastPadding, AlignmentGeometry? globalToastAlignment, TextStyle? globalToastTextStyle, BoxDecoration? globalToastDecoration}) → void
初始化基础样式(已废弃,请使用 initStyleConfig)
initStyleConfig({ToastStyleConfig? styleConfig, ToastAnimationConfig? animationConfig}) → void
初始化样式配置
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

如果不关心,context调用,需在入口函数的 MaterialApp( navigatorKey: Toast.navigatorState ) 添加绑定 如果路由2.0 则使用 RouterDelegate 下面的 navigatorKey
final

Static Methods

cancel(OverlayEntryManger? manger) → void
cancelAll() → void
取消toast 显示
closeLoading() → void
关闭加载动画
show(String msg, {BuildContext? context, BuildToastStyle? buildToastStyle, ToastPosition? position, int? showTime, BuildOverlayStyle? buildOverlayStyle, Color backgroundColor = Colors.transparent, ToastAnimationConfig? animationConfig, ToastStyleConfig? styleConfig}) Future<OverlayEntryManger?>
显示一个吐司
showCustomPoint({BuildContext? context, BuildToastStyle? buildToastStyle, required BuildToastPoint buildToastPoint, int? showTime}) Future<OverlayEntryManger?>
显示自定义坐标的吐司
showLoading({Widget? child, Color? backgroundColor, bool barrierDismissible = false, BuildContext? context, bool enableAnimation = true, int animationDuration = 300}) → void
显示加载动画 child 自定义加载组件,如果为 null 则使用默认的 CircularProgressIndicator backgroundColor 背景颜色,默认半透明黑色 barrierDismissible 点击背景是否可以取消显示,默认 false context 上下文,如果为 null 则使用 navigatorState enableAnimation 是否启用淡入淡出动画,默认 true animationDuration 动画持续时间(毫秒),默认 300
showQueueToast(String msg, {bool status = true, BuildContext? context, BuildToastQueueStyle? buildStyle, Duration showTime = const Duration(milliseconds: 2000), Duration animationTime = const Duration(milliseconds: 600), Offset startOffset = const Offset(0, 0), Offset endOffset = const Offset(0, -100), ScalingFactor mobile = const ScalingFactor(0.7, 0.7), ScalingFactor tablet = const ScalingFactor(0.5, 0.7), ScalingFactor desktop = const ScalingFactor(0.3, 0.7), SizedBox divider = const SizedBox(height: 10)}) → void
支持队列的方式显示多个 toast 默认自下向上退出 显示的宽高受最大 ScalingFactor 缩放因子决定
showStatus(String msg, {bool status = true, BuildContext? context, double? width, double? height, double radius = 10, Color? bgColor = Colors.white, Color? toastBgColor = const Color(0x77000000), Color? iconColorSuccess = const Color(0xFF3EC3CF), Color? iconColorError = Colors.redAccent, double? iconSize = 26, TextStyle? textStyle = const TextStyle(color: Colors.black), int? showTime, EdgeInsetsGeometry padding = const EdgeInsets.symmetric(horizontal: 20, vertical: 10), EdgeInsetsGeometry margin = const EdgeInsets.symmetric(horizontal: 20, vertical: 10)}) → void
模板代码,外部可参考定制自己的各种状态样式