Customizing Notification Sounds, Vibration & LED in Flutter
FlutterPulseThis article was translated specially for the channel FlutterPulseYou'll find lots of interesting things related to Flutter on this channel. Don't hesitate to subscribe!π

Push notifications are great for engaging users, but default alerts may not always suit your app's branding or user experience. In thisβ¦
Push notifications are great for engaging users, but default alerts may not always suit your app's branding or user experience. In this guide, we'll customize:
β
Notification Sounds β Use a custom sound instead of the default one πΆ
β
Vibration Patterns β Define unique haptic feedback π
β
LED Lights (Android) β Set different colors for notifications π
We'll implement these features using flutter_local_notifications and Firebase Cloud Messaging (FCM).
Step 1: Add Dependencies
Modify pubspec.yaml to include:
dependencies:
flutter_local_notifications: latest_version
firebase_messaging: latest_version
Run:
flutter pub get
Step 2: Configure Notification Channel (Android Only)
Android requires a notification channel to use custom sounds and LED lights.
Modify AndroidManifest.xml
Navigate to:
π android/app/src/main/AndroidManifest.xml
Inside <application> tag, add:
<uses-permission android:name="android.permission.VIBRATE"/>
Step 3: Setting Up Custom Sounds π΅
1. Add Sound Files
Place your custom sound file (custom_sound.mp3) in:
π android/app/src/main/res/raw/custom_sound.mp3
If raw folder doesn't exist, create it manually.
2. Register Custom Sound in Flutter
Modify the notification details:
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
void showCustomSoundNotification() async {
const AndroidNotificationDetails androidDetails = AndroidNotificationDetails(
'custom_sound_channel',
'Custom Sound Notifications',
sound: RawResourceAndroidNotificationSound('custom_sound'), // Remove file extension
importance: Importance.high,
priority: Priority.high,
);
const NotificationDetails details = NotificationDetails(android: androidDetails);
await flutterLocalNotificationsPlugin.show(
0,
"Custom Sound Alert",
"This notification uses a custom sound!",
details,
);
}
π οΈ Note: iOS requires sound files in .caf or .aiff format. Place them in ios/Runner/Resources.
Step 4: Customizing Vibration Patterns ποΈ
Modify the vibration pattern to create different haptic effects:
const AndroidNotificationDetails androidDetails = AndroidNotificationDetails(
'vibration_channel',
'Vibration Notifications',
vibrationPattern: Int64List.fromList([0, 500, 1000, 500, 2000, 500]),
enableVibration: true,
importance: Importance.high,
);
π‘ How It Works:
0β No delay before vibration500β Vibrate for 500ms1000β Pause for 1000ms- Repeat for different intervals
Step 5: Customizing LED Lights (Android Only) π
Modify notification details to change LED color:
const AndroidNotificationDetails androidDetails = AndroidNotificationDetails(
'led_channel',
'LED Notifications',
enableLights: true,
ledColor: Color(0xFFFF0000), // Red LED
ledOnMs: 1000,
ledOffMs: 500,
importance: Importance.high,
);
Step 6: Implementing Custom Notifications in Firebase Messaging
1. Modify Firebase Cloud Messaging (FCM) Payload
When sending notifications from FCM, modify the payload to include custom sounds & vibration:
{
"to": "/topics/all",
"notification": {
"title": "New Alert!",
"body": "This is a custom notification",
"sound": "custom_sound"
},
"android": {
"notification": {
"sound": "custom_sound",
"vibrate_timings": ["0s", "0.5s", "1s", "1.5s"],
"light_settings": {
"color": "#FF0000",
"light_on_duration": "1s",
"light_off_duration": "0.5s"
}
}
}
}Step 7: Testing Custom Notifications
1οΈβ£ Send FCM Notification via Postman or Firebase Console
2οΈβ£ Check if sound, vibration, and LED changes reflect
3οΈβ£ Modify settings dynamically for user preferences
Conclusion
π You've successfully customized notifications in Flutter! π
β
Custom Sounds π΅
β
Vibration Patterns π
β
LED Light Colors π
π¬ Have questions? Let me know in the comments! π
If you found this story helpful, you can support me at Buy Me a Coffee!