createView method
Future
createView({
- required String message,
- required BuildContext context,
- BoxDecoration? decoration,
- AlignToast alignToast = AlignToast.top,
- double fontSize = size14,
- Widget? icon,
- FontWeight fontWeight = fontWeigh500,
- Color fontColor = whiteColor,
- int durationMilliSeconds = 2500,
Implementation
Future createView(
{required String message,
required BuildContext context,
BoxDecoration? decoration,
AlignToast alignToast = AlignToast.top,
double fontSize = size14,
Widget? icon,
FontWeight fontWeight = fontWeigh500,
Color fontColor = whiteColor,
int durationMilliSeconds = 2500}) async {
if (isVisible) {
return;
}
isVisible = true;
overlayState = Overlay.of(context)!;
overlayEntry = OverlayEntry(
builder: (BuildContext context) => Positioned(
child: SafeArea(
child: ToastAnimateState(
alignToast: alignToast,
fontWeight: fontWeight,
icon: icon,
endTween: alignToast == AlignToast.top ? 10.0 : -10.0,
startTween: alignToast == AlignToast.top ? -5.0 : 5.0,
fontSize: fontSize,
fontColor: fontColor,
decoration: decoration,
message: message,
durationSeconds: durationMilliSeconds,
removeWidget: () {
if (overlayState != null) {
if (overlayEntry != null && overlayEntry!.mounted) {
overlayEntry!.remove();
isVisible = false;
}
}
},
)),
top: alignToast == AlignToast.top
? MediaQuery.of(context).viewInsets.top + 5
: null,
bottom: alignToast == AlignToast.bottom
? MediaQuery.of(context).viewInsets.bottom + 20
: null,
key: UniqueKey(),
));
overlayState!.insert(overlayEntry!);
}