show static method
void
show(
- BuildContext context, {
- required String message,
- Color backgroundColor = const Color(0xE6000000),
- Color textColor = Colors.white,
- TextStyle? textStyle,
- IconData? icon,
- double? iconSize,
- Duration duration = const Duration(seconds: 2),
- EdgeInsets margin = const EdgeInsets.symmetric(horizontal: 24, vertical: 64),
- EdgeInsetsGeometry padding = const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
- double radius = 12.0,
- double elevation = 2.0,
- Color? shadowColor,
- Color? borderColor,
- double borderWidth = 1.0,
- bool top = false,
- int maxLines = 4,
- TextOverflow overflow = TextOverflow.ellipsis,
Base overlay toast.
Implementation
static void show(
BuildContext context, {
required String message,
Color backgroundColor = const Color(0xE6000000),
Color textColor = Colors.white,
TextStyle? textStyle,
IconData? icon,
double? iconSize,
Duration duration = const Duration(seconds: 2),
EdgeInsets margin = const EdgeInsets.symmetric(
horizontal: 24,
vertical: 64,
),
EdgeInsetsGeometry padding = const EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
double radius = 12.0,
double elevation = 2.0,
Color? shadowColor,
Color? borderColor,
double borderWidth = 1.0,
bool top = false,
int maxLines = 4,
TextOverflow overflow = TextOverflow.ellipsis,
}) {
if (_entry != null) {
_removeInstantly();
}
_toastKey = GlobalKey<_ToastBubbleState>();
_entry = OverlayEntry(
builder: (ctx) {
return Positioned(
top: top ? margin.top : null,
bottom: top ? null : margin.bottom,
left: margin.left,
right: margin.right,
child: Material(
type: MaterialType.transparency,
child: _ToastBubble(
key: _toastKey,
message: message,
backgroundColor: backgroundColor,
textColor: textColor,
textStyle: textStyle,
icon: icon,
iconSize: iconSize,
duration: duration,
padding: padding,
radius: radius,
elevation: elevation,
shadowColor: shadowColor,
borderColor: borderColor,
borderWidth: borderWidth,
top: top,
maxLines: maxLines,
overflow: overflow,
onDismissed: () {
_removeInstantly();
},
),
),
);
},
);
Overlay.of(context).insert(_entry!);
}