ToastStyle class

Toast样式配置类

这个类提供了一种统一的方式来管理Toast的所有视觉样式参数 封装了字体、颜色、圆角和图标等配置,使Toast创建更加灵活

使用示例:

final style = ToastStyle(
  fontSize: 16.0,
  backgroundColor: Colors.black87,
  textColor: Colors.white,
  borderRadius: 8.0,
);

DencendToast.showToast(
  msg: "自定义样式Toast",
  toastStyle: style,
);

设计特点:

  • 不可变类:确保配置创建后不会被意外修改
  • 可空字段:允许部分自定义,其他使用默认值
  • 预设默认值:提供合理的初始样式
  • 跨平台支持:包括Web特定的CSS渐变支持

Constructors

ToastStyle({double? fontSize, String? fontAsset, Color? backgroundColor, Color? textColor, double? borderRadius, String? iconAsset, double? iconSize, Color? iconColor, ToastIconPosition? iconPosition, double? iconSpacing, dynamic webBgColor = "linear-gradient(to right, #00b09b, #96c93d)"})
构造函数
const

Properties

backgroundColor Color?
背景颜色
final
borderRadius double?
圆角大小
final
fontAsset String?
自定义字体资源路径
final
fontSize double?
字体大小
final
hashCode int
The hash code for this object.
no setterinherited
iconAsset String?
图标资源路径
final
iconColor Color?
图标颜色
final
iconPosition ToastIconPosition?
图标位置
final
iconSize double?
图标大小
final
iconSpacing double?
图标与文字的间距
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
textColor Color?
文本颜色
final
webBgColor → dynamic
Web平台背景颜色,支持CSS渐变字符串
final

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