Search packages, repositories and app categories

Package detailsv3.2.0

flutter_notification_channel

A plugin for setting up notification channels on android

AndroidiOS
30-day downloads
3.9K
Likes
33
Pub points
120

Install package

flutter pub add flutter_notification_channel

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The flutter_notification_channel package enables developers to easily configure and manage notification channels on Android devices within Flutter applications. It provides a straightforward API to create, update, and customize notification channels, ensuring notifications are properly categorized and displayed according to Android's notification channel requirements. The package supports both Android and iOS platforms, though its primary functionality is focused on Android's channel-based notification system. It helps improve user experience by allowing granular control over notification behavior, such as sound, vibration, and importance levels.

Use cases

  • Configuring custom notification channels
  • Managing notification importance levels
  • Customizing notification sounds and vibrations
  • Ensuring compliance with Android 8.0+ notification requirements
  • Improving user experience with organized notifications

Key features

  • Simple API for creating notification channels
  • Support for Android 8.0+ channel requirements
  • Cross-platform compatibility (Android & iOS)
  • Configurable channel properties like importance and sound
  • Easy integration with existing notification systems

Suitable for

  • Apps requiring structured notification management
  • Developers targeting Android 8.0+ devices
  • Projects needing customizable notification behaviors
  • Teams building apps with multiple notification types
  • Flutter apps that use push notifications

Considerations

  • Primary functionality is limited to Android
  • iOS support is minimal (no channel creation)
  • Requires manual handling of platform-specific logic
  • Not needed for basic notifications on older Android versions
  • Best used in conjunction with other notification plugins

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

flutter_notification_channel

https://pub.dev/packages/flutter_notification_channel

This plugin is made to register notification channels with custom configurations on Android. For more details read this https://developer.android.com/training/notify-user/channels Why is it necessary? E.g. firebase_messaging version 7.0.3 (current) and lower do not allow to set up a notification channel, thus notifications don't play any sounds or do not display on locked screen, or don't bubble and so on. This plugin is made merely for the purpose of creation a notification channel with custom configurations on Android. The channels then can be used along with firebase_messaging.

How to use

Simply call it like this

var result = await FlutterNotificationChannel().registerNotificationChannel(
    description: 'Your channel description',
    id: 'your_channel_id',
    importance: NotificationImportance.IMPORTANCE_HIGH,
    name: 'Your channel name',
    visibility: NotificationVisibility.VISIBILITY_PUBLIC,
    allowBubbles: true,
    enableVibration: true,
    enableSound: true,
    showBadge: true,
);
print(result);

Importance Levels

The plugin supports the following notification importance levels:

  • NotificationImportance.IMPORTANCE_MIN (1): Minimal importance, might not be shown
  • NotificationImportance.IMPORTANCE_LOW (2): Low importance, shows in shade and potentially status bar but not audibly intrusive
  • NotificationImportance.IMPORTANCE_DEFAULT (3): Default importance, shows everywhere and makes noise but doesn't visually intrude
  • NotificationImportance.IMPORTANCE_HIGH (4): Higher importance, shows everywhere, makes noise and peeks, may use full screen intents
  • NotificationImportance.IMPORTANCE_MAX (5): Maximum importance, most intrusive level, should be used sparingly for critical notifications only
Example with Maximum Importance

For critical notifications that require immediate user attention:

var result = await FlutterNotificationChannel().registerNotificationChannel(
    description: 'Critical system alerts',
    id: 'critical_channel_id',
    importance: NotificationImportance.IMPORTANCE_MAX,
    name: 'Critical Alerts',
    visibility: NotificationVisibility.VISIBILITY_PUBLIC,
    allowBubbles: true,
    enableVibration: true,
    enableSound: true,
    showBadge: true,
);

Then, when you send a message to firebase like this, specify your android_channel_id and sound: "default" in order to play a default sound if you set "enableSound" in plugin. If you don't do this, the sound wont play at all on android 9 (I have no idea why)

{
  "notification": {
    "title": "Your message title",
    "body": "Your message body",
    "android_channel_id": "your_channel_id",
    "sound": "default"
  },
  "data": {
    "click_action" : "FLUTTER_NOTIFICATION_CLICK",
  },
  "priority": "high",
  "content_available": true,
  "to": "YOUR_FIREBASE_PUSH_TOKEN_GOES_HERE"
}

Categories

Dependencies

Dependency list 1 items

  • plugin_platform_interface^2.1.8

Source repository

Projects using this package

No data available yet.