showToast static method
void
showToast({
- required BuildContext context,
- required String text,
- UpStyle? style,
- UpColorType? upColorType,
- bool isRounded = false,
- double borderRadius = 25.0,
- UpToastType upToastType = UpToastType.primary,
- EdgeInsetsGeometry? padding,
- Icon? icon,
- Duration? duration,
- double width = 300,
- double? height,
Implementation
static void showToast({
required BuildContext context,
required String text,
UpStyle? style,
UpColorType? upColorType,
bool isRounded = false,
double borderRadius = 25.0,
UpToastType upToastType = UpToastType.primary,
EdgeInsetsGeometry? padding,
Icon? icon,
Duration? duration,
double width = 300,
double? height,
}) async {
if (_isVisible) {
return;
}
_isVisible = true;
final OverlayState overlayState = Overlay.of(context);
final OverlayEntry overlayEntry = OverlayEntry(
builder: (BuildContext context) => _UpToast(
style: style,
colorType: upColorType,
text: text,
isRounded: isRounded,
borderRadius: borderRadius,
upToastType: upToastType,
icon: icon,
padding: padding,
width: width,
height: height,
),
);
overlayState.insert(overlayEntry);
await Future.delayed(duration ?? const Duration(seconds: 2));
overlayEntry.remove();
_isVisible = false;
}