Flutter Local Notification

Add package flutter_local_notifications: to pubspec.yaml.

Add a icons to android/app/src/main/res/drawable/icon.png this will show in notification.

Notification service class

class NotificationServices {
  final notificationPlugin = FlutterLocalNotificationsPlugin();

  void initNotification() async {
    var initializationSettingsAndroid = const AndroidInitializationSettings(

    var initializationSettingsIOS = DarwinInitializationSettings(
      requestAlertPermission: true,
      requestBadgePermission: true,
      requestSoundPermission: true,
      onDidReceiveLocalNotification: (id, title, body, payload) async {},

    var initializationSettings = InitializationSettings(
      android: initializationSettingsAndroid,
      iOS: initializationSettingsIOS,

    await notificationPlugin.initialize(
      onDidReceiveNotificationResponse: (payload) async {

  NotificationDetails notificationDetails() {
    return const NotificationDetails(
      android: AndroidNotificationDetails(
        'channel id',
        'channel name',
        importance: Importance.max,
      iOS: DarwinNotificationDetails(),

  Future showNotification({
    required int id,
    required String title,
    required String body,
    String? payload,
  }) async {
    return notificationPlugin.show(

Go to ios/Runner/AppDelegate.swift

import UIKit
import Flutter
import GoogleMaps

import flutter_local_notifications

@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {

    FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
      GeneratedPluginRegistrant.register(with: registry)

    GeneratedPluginRegistrant.register(with: self)

    if #available(iOS 10.0, *) {
      UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate

    return super.application(application, didFinishLaunchingWithOptions: launchOptions)

Add the red code.

Thats it. Now whenever you need to show a notification just call showNotfication();


Leave a Comment

Your email address will not be published. Required fields are marked *