NotificationChannel class final

Describes an Android notification channel.

Notification channels are required on Android 8.0+ (API 26+). Each channel defines a display name, importance level, and audio/vibration behaviour that users can customise in system settings.

Pre-defined channels are provided as static constants. Create custom channels via the constructor:

const myChannel = NotificationChannel(
  id: 'order_updates',
  name: 'Order Updates',
  description: 'Notifications about your orders.',
  importance: PkNotificationImportance.high,
);

Constructors

NotificationChannel({required String id, required String name, String? description, PkNotificationImportance importance = PkNotificationImportance.defaultImportance, bool playSound = true, bool enableVibration = true, bool enableLights = false})
Creates a notification channel definition.
const

Properties

description String?
Optional user-visible description of this channel's purpose.
final
enableLights bool
Whether notifications on this channel flash the device LED.
final
enableVibration bool
Whether notifications on this channel trigger vibration.
final
hashCode int
The hash code for this object.
no setterinherited
id String
Unique channel identifier. Must be stable across app versions.
final
importance PkNotificationImportance
The channel importance level, controlling how prominently notifications are shown. Defaults to PkNotificationImportance.defaultImportance.
final
name String
User-visible channel name shown in system notification settings.
final
playSound bool
Whether notifications on this channel play a sound.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

copyWith({String? id, String? name, String? description, PkNotificationImportance? importance, bool? playSound, bool? enableVibration, bool? enableLights}) NotificationChannel
Returns a copy with the given fields replaced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

alerts → const NotificationChannel
High-importance alerts requiring immediate attention.
general → const NotificationChannel
General-purpose notifications (news, reminders, non-urgent updates).
marketing → const NotificationChannel
Marketing and promotional messages.