showCustomToast method
void
showCustomToast(
- BuildContext context,
- String message, {
- Duration duration = const Duration(seconds: 4),
Implementation
void showCustomToast(BuildContext context, String message,
{Duration duration = const Duration(seconds: 4)}) {
final overlayState = _resolveOverlayState(context);
if (overlayState == null) {
debugPrint("⛔ PartnerLibrary: Unable to find OverlayState for toast.");
return;
}
final overlayEntry = OverlayEntry(
builder: (ctx) => Positioned(
bottom: MediaQuery.of(ctx).viewInsets.bottom,
width: MediaQuery.of(ctx).size.width,
child: CustomToast(message: message),
),
);
overlayState.insert(overlayEntry);
Future.delayed(duration, () {
overlayEntry.remove();
});
}