addToastNotifications method

void addToastNotifications(
  1. Map<String, dynamic> styles
)

Add toast notification styles to the registry. Pass a map of style IDs to widget factory functions. Accepts both ToastStyleFactory (static) and ToastStyleDataFactory (data-aware) values.

Example:

nylo.addToastNotifications({
  'success': ToastNotification.style(
    icon: Icon(Icons.check, color: Colors.green, size: 20),
    color: Colors.green.shade50,
    defaultTitle: 'Success',
  ),
  'new_follower': (data) => ToastNotification.style(
    icon: CircleAvatar(backgroundImage: NetworkImage(data['avatar'])),
    color: Colors.white,
    defaultTitle: "${data['name']} followed you",
  ),
});

Implementation

void addToastNotifications(Map<String, dynamic> styles) {
  ToastNotificationRegistry.instance.registerAll(styles);
}