showNotification function
SonnerNotification
showNotification({
- NotificationData? data,
- NotificationPriority priority = NotificationPriority.high,
- Alignment alignment = Alignment.bottomCenter,
- required Widget builder(),
Show a notification and return a controllable instance
This function tries to use the global context. Make sure NotificationProvider is in the widget tree.
Implementation
SonnerNotification showNotification({
NotificationData? data,
NotificationPriority priority = NotificationPriority.high,
Alignment alignment = Alignment.bottomCenter,
required Widget Function(BuildContext, NotificationData, SonnerNotification) builder,
}) {
// Get the current context from the provider
final context = NotificationProvider.currentContext;
if (context == null) {
throw StateError('NotificationProvider not found. Make sure to wrap your app with NotificationProvider.');
}
return NotificationProvider.of(context).showNotification(
data: data,
priority: priority,
alignment: alignment,
builder: builder,
);
}