open static method
void
open(})
Implementation
static void open(
BuildContext context, {
double bottom = 24,
Widget? btn,
Widget? closeIcon,
required Widget description,
Duration? duration = const Duration(milliseconds: 4500),
Widget? icon,
required Widget message,
Placement placement = Placement.topRight,
double top = 24,
void Function()? onClick,
void Function()? onClose,
}) {
var tops = GlobalQuery.of(context)?.notificationTops;
var realTop = top;
if (tops != null) {
var heights = tops.values.toList();
for (int i = 0; i < heights.length; i++) {
realTop += heights[i] + 16;
}
}
var key = GlobalKey();
var entry = OverlayEntry(
builder: (_) => _Notification(
key: key,
bottom: bottom,
btn: btn,
closeIcon: closeIcon,
description: description,
duration: duration,
icon: icon,
message: message,
placement: placement,
top: realTop,
onClick: onClick,
onClose: onClose,
),
);
Overlay.of(context)?.insert(entry);
var height = key.currentContext?.size?.height ?? 120;
GlobalQuery.of(context)?.insertNotification(key, height);
if (duration != null) {
Timer(duration, () {
entry.remove();
GlobalQuery.of(context)?.removeNotification(key);
});
}
}