show static method
void
show(
- BuildContext context, {
- required String message,
- NiceNotificationType type = NiceNotificationType.info,
- Duration duration = const Duration(seconds: 3),
- String? actionLabel,
- VoidCallback? onAction,
Show a toast notification
Implementation
static void show(
BuildContext context, {
required String message,
NiceNotificationType type = NiceNotificationType.info,
Duration duration = const Duration(seconds: 3),
String? actionLabel,
VoidCallback? onAction,
}) {
final overlay = Overlay.of(context);
late OverlayEntry entry;
entry = OverlayEntry(
builder: (context) => Positioned(
bottom: 50,
left: 0,
right: 0,
child: Center(
child: Material(
color: Colors.transparent,
child: NiceToast(
message: message,
type: type,
duration: duration,
actionLabel: actionLabel,
onAction: onAction,
onDismiss: () => entry.remove(),
),
),
),
),
);
overlay.insert(entry);
Future.delayed(duration, () {
if (entry.mounted) {
entry.remove();
}
});
}