Go to pubspec.yaml and add dependency from here
app_icon needs to be a added as a drawable resource to the Android head project. Path should be as follows
project-name/android/app/src/main/res/drawable/app_icon.png
Note: Icon should be a material icon for android. It will be grayed out.
Notification manager class depends on Strings.dart which is mainly being used for two strings mentioned here
Strings.package and Strings.app_name
You can either use strings class or just replace these two with your app name and package name
Initialize notification manager in your first screen. If your first screen is stateful widget then integrate it in init method else initialize in build method if its a stateless widget
NotificationManager.instance.init()
Now in order to schedule notifications there are many methods inside notifcations class but we are use following code block right now
scheduleAllNotifications(List<NotificationModel> data) async {
await _cancelAllNotifications();
var days = 1;
data.forEach((item) {
_scheduleNotificationDaily(item, Duration(days: days));
days += 7;
});
}
I am cancelling all the notifications scheduled before and scheduling it again. You can use your own logic to implement this method.
In order to send it data we are using season class as follows:
NotificationManager.instance.scheduleAllNotifications(Season.data()
.map((e) => NotificationModel(
id: e.hashCode, title: e.title, body: e.description))
.toList());
I am building notification model and sending all the notifications at once.
and Voila. You are done.