title: Flutter local notifcation error, I have been trying to create headsup notification
body: <p>This is my local_notification_settings.dart</p>
  <pre><code>import 'package:firebase_messaging/firebase_messaging.dart';
  import 'package:flutter_local_notifications/flutter_local_notifications.dart';
  
  class LocalNotificationService{
    static final FlutterLocalNotificationsPlugin _notificationsPlugin = FlutterLocalNotificationsPlugin();
  
  
    static void initialize(){
      final InitializationSettings initializationSettings =
          InitializationSettings(
              android: AndroidInitializationSettings('@mipmap/ic_launcher'));
  
    
      
    }
    static void display(RemoteMessage message)async{
      try {
        final id  = DateTime.now().millisecondsSinceEpoch ~/1000;
        final NotificationDetails notificationDetails = NotificationDetails(
          android: AndroidNotificationDetails(
            &quot;intraday&quot;,
            &quot;intraday channel&quot;,
            channelDescription: &quot;this is intraday channel&quot;,
            importance: Importance.max,
            priority: Priority.high
          )
        );
        await _notificationsPlugin.show(id, message.notification!.title,
        message.notification!.body, notificationDetails);
      } on Exception catch (e) {
            print(e);
      }
    }
  }
  </code></pre>
  <p>And this is my main.dart file:</p>
  <pre><code>import 'package:firebase_core/firebase_core.dart';
  import 'package:flutter/material.dart';
  import 'package:flutter_local_notifications/flutter_local_notifications.dart';
  import 'package:stock_market/pages/Models/news.dart';
  import 'package:stock_market/pages/blogSpotHome.dart';
  import 'package:stock_market/pages/bottomNavigation.dart';
  import 'package:stock_market/pages/detailedPage.dart';
  import 'package:stock_market/pages/investment_from_db.dart';
  import 'package:stock_market/pages/options_from_db.dart';
  import 'package:stock_market/pages/stock_from_db.dart';
  import 'package:stock_market/pages/utils/route.dart';
  import 'package:stock_market/pages/widgets/topNavigation.dart';
  import 'package:stock_market/pages/widgets/newTile.dart';
  import 'package:stock_market/pages/widgets/themes.dart';
  import 'package:stock_market/services/local_notification_services.dart';
  import 'pages/home_page.dart';
  import 'pages/login.dart';
  import 'package:bottom_nav_layout/bottom_nav_layout.dart';
  import 'package:firebase_messaging/firebase_messaging.dart';
  import 'package:flutter_notification_channel/flutter_notification_channel.dart';
  import 'package:flutter_notification_channel/notification_importance.dart';
  Future&lt;void&gt; _messageHandler(RemoteMessage message) async {
  
    print('background message ${message.notification!.body}');
  }
  
  void main() async {
    WidgetsFlutterBinding.ensureInitialized();
    LocalNotificationService.initialize();
   
    await Firebase.initializeApp();
    await  FirebaseMessaging.instance.subscribeToTopic(&quot;intraday&quot;);
     await  FirebaseMessaging.instance.subscribeToTopic(&quot;options&quot;);
       await  FirebaseMessaging.instance.subscribeToTopic(&quot;investment&quot;);
         await  FirebaseMessaging.instance.subscribeToTopic(&quot;blog&quot;);
  
  
    // If `onMessage` is triggered with a notification, construct our own
    // local notification to show to users using the created channel.
    // if (notification != null &amp;&amp; android != null) {
    //   flutterLocalNotificationsPlugin.show(
    //       notification.hashCode,
    //       notification.title,
    //       notification.body,
    //       NotificationDetails(
    //         android: AndroidNotificationDetails(
    //           channel.id,
    //           channel.name,
    //           channelDescription: channel.description,
    //           icon: android.smallIcon,
    //           // other properties...
    //         ),
    //       ));
    // }
  
  
    runApp(MyApp());
  }
  
  // class MyApp extends StatefulWidget {
  //   const MyApp({ Key? key }) : super(key: key);
  
  //   @override
  //   _MyAppState createState() =&gt; _MyAppState();
  
  // }
  
  // class _MyAppState extends State&lt;MyApp&gt; {
  //   FirebaseMessaging messaging = FirebaseMessaging.instance;
  //   // var androidSettings = AndroidInitializationSettings('app_icon');
  //    @override
  //   initState() {
  //     super.initState();
  //     ///app in background and user taps it
  //     FirebaseMessaging.onMessageOpenedApp.listen((message) {
  //       final routeFromMessage = message.data[&quot;route&quot;];
  //       Navigator.of(context).pushNamed(routeFromMessage);
  
  
  
  //      });
  //     // ignore: unused_local_variable
  //     // var initializationSettingsAndroid =AndroidInitializationSettings('app_icon');
  
  //   }
  
  //   // void messagingF() async{
  //   //     messaging.
  //   // } 
  
  
    
  
    
  
  
    
  
  //   @override
  //   Widget build(BuildContext context) {
  //     return MaterialApp (
  //     themeMode: ThemeMode.light,
  //     theme: MyTheme.lightTheme(context),
  //     darkTheme: MyTheme.darkTheme(context),
  //     debugShowCheckedModeBanner: false,
  //       home: MyHome(),
  
  //     );
      
      
      
   
  //   }
  // }
  // Future&lt;void&gt; _createNotificationChannel(String id, String name,
  //     String description) async {
  //   final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
  //   var androidNotificationChannel = AndroidNotificationChannel(
  //     id,
  //     name,
     
  //   );
    
  //   await flutterLocalNotificationsPlugin
  //       .resolvePlatformSpecificImplementation&lt;
  //       AndroidFlutterLocalNotificationsPlugin&gt;()
  //       ?.createNotificationChannel(androidNotificationChannel);
        
        
  //     }
  
  
  class MyApp extends StatelessWidget {
  
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        debugShowCheckedModeBanner: false,
  
              routes: {
           MyRoute.homeRoute: (context) =&gt; MyHome(),
          // &quot;/&quot;: (context) =&gt; WithTabBar(),
          &quot;1&quot;: (_) =&gt; OptionsRoute(),
          &quot;2&quot;: (_) =&gt; InvestMentRoute(),
          &quot;3&quot;: (_) =&gt; NewsPage(),
          // &quot;/news&quot;: (context) =&gt; const NewsPage(),
          // &quot;/investment&quot;: (context) =&gt; const InvestMentRoute(),
         
          // MyRoute.dbRoute: (context) =&gt; DbRoute(),
          //  MyRoute.news: (context)  =&gt; NewsPage()
            
        },
              themeMode: ThemeMode.light,
        theme: MyTheme.lightTheme(context),
        // darkTheme: MyTheme.darkTheme(context),
        //       debugShowCheckedModeBanner: false,
          // home: Nav(),
          // home:MyHome()
        // home: HomePage(),]
        // initialRoute: MyRoute.news,
        // routes: {
        //   // MyRoute.loginRoute: (context) =&gt; LoginPage(),
        //   // MyRoute.homeRoute: (context) =&gt; HomePage(),
        //   // MyRoute.dbRoute: (context) =&gt; DbRoute(),
        //   //  MyRoute.news: (context) =&gt; MainNews()
            
        // },
  
      );
     
    }
  }
  class MyHome extends StatefulWidget {
    const MyHome({ Key? key }) : super(key: key);
  
    @override
    _MyHomeState createState() =&gt; _MyHomeState();
  }
  
  class _MyHomeState extends State&lt;MyHome&gt; {
     @override
    initState() {
      super.initState();
      FirebaseMessaging.instance.getInitialMessage().then((message){
          if (message != null) {
               final routeFromMessage = message.data[&quot;route&quot;];
                  Navigator.of(context).pushNamed(routeFromMessage);
            
      print('Message also contained a notification: ${message.notification}');
    }
  
  
      });
      ///app in background and user taps it
      FirebaseMessaging.onMessageOpenedApp.listen((message) {
        final routeFromMessage = message.data[&quot;route&quot;];
              Navigator.of(context).pushNamed(routeFromMessage);
         
         
  
      
          // Navigator.push(
          //         context,
          //          MaterialPageRoute(builder: (context) =&gt; routeFromMessage()),
          //       );
    // Navigator.pushNamed(context, routeFromMessage);
   
  
  
        // pushNamed(routeFromMessage);
            //  
  
  
       });
  
  
      FirebaseMessaging.onMessage.listen(( message) {
        
    // print('Got a message whilst in the foreground!');
    // print('Message data: ${message.data}');
  
    if (message.notification != null) {
      print('Message also contained a notification: ${message.notification}');
    }
    LocalNotificationService.display(message);  
  
  });
    }
    @override
    Widget build(BuildContext context) {
          if (mounted){
          setState(() {
       WithTabBar();
      });
      }
   
   return WithTabBar(
  
          // home: Nav(),
          // home:WithTabBar(),
  
    
          
        // home: HomePage()
        // initialRoute:&quot;/&quot;,
  
  
      );
      
    }
  }
  </code></pre>
  <p>And this is my androidmanifest.xml file:</p>
  <pre><code>    &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.example.stock_market&quot;&gt;
         &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
     &lt;application
          android:label=&quot;stock_market&quot;
          android:icon=&quot;@mipmap/ic_launcher&quot;&gt;
  
          &lt;meta-data
          android:name=&quot;com.google.firebase.messaging.default_notification_icon&quot;
          android:resource=&quot;@mipmap/ic_launcher&quot; /&gt;
        
          &lt;activity
              android:name=&quot;.MainActivity&quot;
              android:launchMode=&quot;singleTop&quot;
              android:theme=&quot;@style/LaunchTheme&quot;
              android:configChanges=&quot;orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode&quot;
              android:hardwareAccelerated=&quot;true&quot;
              android:windowSoftInputMode=&quot;adjustResize&quot;&gt;
              &lt;!-- Specifies an Android theme to apply to this Activity as soon as
                   the Android process has started. This theme is visible to the user
                   while the Flutter UI initializes. After that, this theme continues
                   to determine the Window background behind the Flutter UI. --&gt;
              &lt;meta-data
                android:name=&quot;io.flutter.embedding.android.NormalTheme&quot;
                android:resource=&quot;@style/NormalTheme&quot;
                /&gt;
              &lt;!-- Displays an Android View that continues showing the launch screen
                   Drawable until Flutter paints its first frame, then this splash
                   screen fades out. A splash screen is useful to avoid any visual
                   gap between the end of Android's launch screen and the painting of
                   Flutter's first frame. --&gt;
              &lt;meta-data
                android:name=&quot;io.flutter.embedding.android.SplashScreenDrawable&quot;
                android:resource=&quot;@drawable/launch_background&quot;
                /&gt;
                &lt;meta-data
                  android:name=&quot;com.google.firebase.messaging.default_notification_channel_id&quot;
                  android:value=&quot;intraday&quot;/&gt;
              &lt;intent-filter&gt;
          
                  &lt;action android:name=&quot;android.intent.action.MAIN&quot;/&gt;
                  &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot;/&gt;
                   &lt;action android:name=&quot;FLUTTER_NOTIFICATION_CLICK&quot;/&gt;
                    &lt;category android:name=&quot;android.intent.category.DEFAULT&quot;/&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;!-- Don't delete the meta-data below.
               This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --&gt;
          &lt;meta-data
              android:name=&quot;flutterEmbedding&quot;
              android:value=&quot;2&quot; /&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  <p>And this is the error I am getting. I know the icon is causing this and I have tried everything but nothing seems to work:</p>
  <pre><code>E/MethodChannel#dexterous.com/flutter/local_notifications( 7850): Failed to handle method call
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.setSmallIcon(FlutterLocalNotificationsPlugin.java:299)
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:214)
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:1023)
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:1358)
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:1240)
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at android.os.MessageQueue.nativePollOnce(Native Method)
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at android.os.MessageQueue.next(MessageQueue.java:336)
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at android.os.Looper.loop(Looper.java:182)
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at android.app.ActivityThread.main(ActivityThread.java:7563)
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at java.lang.reflect.Method.invoke(Native Method)
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
  E/MethodChannel#dexterous.com/flutter/local_notifications( 7850):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:994)
  I/flutter ( 7850): PlatformException(error, Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
  I/flutter ( 7850):  at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.setSmallIcon(FlutterLocalNotificationsPlugin.java:299)
  I/flutter ( 7850):  at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:214)
  I/flutter ( 7850):  at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:1023)
  I/flutter ( 7850):  at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:1358)
  I/flutter ( 7850):  at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:1240)
  I/flutter ( 7850):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
  I/flutter ( 7850):  at io
  </code></pre>
  <p>I have tried copying icon to different location and tried every solution available online.</p>