Today I’ll tell you that how you can setup Local Notification Plugin on Flutter App. Using Plugin in flutter is not difficult but in case of Flutter Local Notification. We need to setup some configuration before start using it.

Flutter Local Notification Youtube Video
dependencies:
flutter:
sdk:
flutter

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
flutter_local_notifications:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flutterappnoti"
>

<!-- The INTERNET permission is required for development. Specifically,
flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
  1. Keep a small Audio (Music) there and remember the file name.

Payload : Notification messages can contain an optional data that is known as payload

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';

void main() {
runApp(
new MaterialApp(home: new MyApp()),
);
}

class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;

@override
initState() {
super.initState();
// initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project
// If you have skipped STEP 3 then change
app_icon to @mipmap/ic_launcher
var initializationSettingsAndroid =
new AndroidInitializationSettings('app_icon');
var initializationSettingsIOS = new IOSInitializationSettings();
var initializationSettings = new InitializationSettings(
initializationSettingsAndroid, initializationSettingsIOS);
flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
flutterLocalNotificationsPlugin.initialize(initializationSettings,
selectNotification: onSelectNotification);
}

@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text('Plugin example app'),
),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new RaisedButton(
onPressed: _showNotificationWithSound,
child: new Text('Show Notification With Sound'),
),
new SizedBox(
height: 30.0,
),
new RaisedButton(
onPressed: _showNotificationWithoutSound,
child: new Text('Show Notification Without Sound'),
),
new SizedBox(
height: 30.0,
),
new RaisedButton(
onPressed: _showNotificationWithDefaultSound,
child: new Text('Show Notification With Default Sound'),
),
],
),
),
),
);
}

Future onSelectNotification(String payload) async {
showDialog(
context: context,
builder: (_) {
return new AlertDialog(
title: Text("PayLoad"),
content: Text("Payload : $payload"),
);
},
);
}
}
// If you have skipped step 4 then Method 1 is not for you

// Method 1
Future _showNotificationWithSound() async {
var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
'your channel id', 'your channel name', 'your channel description',
sound: 'slow_spring_board',
importance: Importance.Max,
priority: Priority.High);
var iOSPlatformChannelSpecifics =
new IOSNotificationDetails(sound: "slow_spring_board.aiff");
var platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(
0,
'New Post',
'How to Show Notification in Flutter',
platformChannelSpecifics,
payload: 'Custom_Sound',
);
}
// Method 2
Future _showNotificationWithDefaultSound() async {
var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
'your channel id', 'your channel name', 'your channel description',
importance: Importance.Max, priority: Priority.High);
var iOSPlatformChannelSpecifics = new IOSNotificationDetails();
var platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(
0,
'New Post',
'How to Show Notification in Flutter',
platformChannelSpecifics,
payload: 'Default_Sound',
);
}
// Method 3
Future _showNotificationWithoutSound() async {
var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
'your channel id', 'your channel name', 'your channel description',
playSound: false, importance: Importance.Max, priority: Priority.High);
var iOSPlatformChannelSpecifics =
new IOSNotificationDetails(presentSound: false);
var platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(
0,
'New Post',
'How to Show Notification in Flutter',
platformChannelSpecifics,
payload: 'No_Sound',
);
}

If you find any difficulties while reading or you have any doubts.
Let me know may be I can help you with that
If you like it then don’t be strange clap before leaving.

Flutter Local Notification has lots of features and it’s little difficult to set up. As I had shown you the basic setup, Now you can go through the official Github Repo and implement other features also. Now you will not face any problem as I had discussed the Setup.

Web🌐/ Mobile📱/ GraphQL / Cloud☁️ . Full-time programmer, part-time content creator, and Freelancer.