NotificationChannel constructor
- required String? channelKey,
- required String? channelName,
- required String? channelDescription,
- String? channelGroupKey,
- bool? channelShowBadge,
- NotificationImportance? importance,
- bool? playSound,
- String? soundSource,
- DefaultRingtoneType? defaultRingtoneType,
- bool? enableVibration,
- Int64List? vibrationPattern,
- bool? enableLights,
- Color? ledColor,
- int? ledOnMs,
- int? ledOffMs,
- String? groupKey,
- GroupSort? groupSort,
- GroupAlertBehavior? groupAlertBehavior,
- String? icon,
- Color? defaultColor,
- bool? locked,
- bool? onlyAlertOnce,
- NotificationPrivacy? defaultPrivacy,
- bool? criticalAlerts,
Constructs a NotificationChannel.
channelKey: Unique identifier for the channel. channelName: Name of the channel. channelDescription: Description of the channel. channelShowBadge: Indicates whether to show a badge for notifications in this channel. importance: The importance level for notifications in this channel. playSound: Indicates whether to play a sound for notifications in this channel. soundSource: The sound resource to play for notifications in this channel. defaultRingtoneType: Default ringtone type for notifications in this channel. enableVibration: Indicates whether to enable vibration for notifications in this channel. vibrationPattern: Vibration pattern for notifications in this channel. enableLights: Indicates whether to enable LED lights for notifications in this channel. ledColor: The color of the LED light for notifications in this channel. ledOnMs: Duration in milliseconds for which the LED light is on. ledOffMs: Duration in milliseconds for which the LED light is off. groupKey: Key for grouping notifications in this channel. groupSort: Sort order for grouped notifications. groupAlertBehavior: Alert behavior for grouped notifications. defaultPrivacy: Default privacy level for notifications in this channel. icon: Icon for notifications in this channel. defaultColor: Default color for notifications in this channel. locked: Indicates whether this channel is locked (cannot be modified or deleted by the user). onlyAlertOnce: Indicates whether to alert only once for notifications in this channel. criticalAlerts: Indicates whether notifications in this channel are critical alerts.
Implementation
NotificationChannel(
{required this.channelKey,
required this.channelName,
required this.channelDescription,
this.channelGroupKey,
this.channelShowBadge,
this.importance,
this.playSound,
this.soundSource,
this.defaultRingtoneType,
this.enableVibration,
this.vibrationPattern,
this.enableLights,
this.ledColor,
this.ledOnMs,
this.ledOffMs,
this.groupKey,
this.groupSort,
this.groupAlertBehavior,
this.icon,
this.defaultColor,
this.locked,
this.onlyAlertOnce,
this.defaultPrivacy,
this.criticalAlerts})
: super() {
channelKey = AwesomeAssertUtils.getValueOrDefault<String>(
NOTIFICATION_CHANNEL_KEY, channelKey);
channelName = AwesomeAssertUtils.getValueOrDefault<String>(
NOTIFICATION_CHANNEL_NAME, channelName);
channelDescription = AwesomeAssertUtils.getValueOrDefault<String>(
NOTIFICATION_CHANNEL_DESCRIPTION, channelDescription);
channelShowBadge = AwesomeAssertUtils.getValueOrDefault<bool>(
NOTIFICATION_CHANNEL_SHOW_BADGE, channelShowBadge);
channelGroupKey = AwesomeAssertUtils.getValueOrDefault<String>(
NOTIFICATION_CHANNEL_GROUP_KEY, channelGroupKey);
importance = AwesomeAssertUtils.getValueOrDefault<NotificationImportance>(
NOTIFICATION_IMPORTANCE, importance);
playSound = AwesomeAssertUtils.getValueOrDefault<bool>(
NOTIFICATION_PLAY_SOUND, playSound);
criticalAlerts = AwesomeAssertUtils.getValueOrDefault<bool>(
NOTIFICATION_CHANNEL_CRITICAL_ALERTS, criticalAlerts);
soundSource = AwesomeAssertUtils.getValueOrDefault<String>(
NOTIFICATION_SOUND_SOURCE, soundSource);
enableVibration = AwesomeAssertUtils.getValueOrDefault<bool>(
NOTIFICATION_ENABLE_VIBRATION, enableVibration);
vibrationPattern = AwesomeAssertUtils.getValueOrDefault<Int64List>(
NOTIFICATION_VIBRATION_PATTERN, vibrationPattern);
enableLights = AwesomeAssertUtils.getValueOrDefault<bool>(
NOTIFICATION_ENABLE_LIGHTS, enableLights);
ledColor = AwesomeAssertUtils.getValueOrDefault<Color>(
NOTIFICATION_LED_COLOR, ledColor);
ledOnMs = AwesomeAssertUtils.getValueOrDefault<int>(
NOTIFICATION_LED_ON_MS, ledOnMs);
ledOffMs = AwesomeAssertUtils.getValueOrDefault<int>(
NOTIFICATION_LED_OFF_MS, ledOffMs);
groupKey = AwesomeAssertUtils.getValueOrDefault<String>(
NOTIFICATION_GROUP_KEY, groupKey);
groupSort = AwesomeAssertUtils.getValueOrDefault<GroupSort>(
NOTIFICATION_GROUP_SORT, groupSort);
groupAlertBehavior =
AwesomeAssertUtils.getValueOrDefault<GroupAlertBehavior>(
NOTIFICATION_GROUP_ALERT_BEHAVIOR, groupAlertBehavior);
icon = AwesomeAssertUtils.getValueOrDefault(NOTIFICATION_ICON, icon);
defaultColor = AwesomeAssertUtils.getValueOrDefault<Color>(
NOTIFICATION_DEFAULT_COLOR, defaultColor);
locked =
AwesomeAssertUtils.getValueOrDefault<bool>(NOTIFICATION_LOCKED, locked);
onlyAlertOnce = AwesomeAssertUtils.getValueOrDefault<bool>(
NOTIFICATION_ONLY_ALERT_ONCE, onlyAlertOnce);
defaultPrivacy = AwesomeAssertUtils.getValueOrDefault<NotificationPrivacy>(
NOTIFICATION_DEFAULT_PRIVACY, defaultPrivacy);
defaultRingtoneType =
AwesomeAssertUtils.getValueOrDefault<DefaultRingtoneType>(
NOTIFICATION_DEFAULT_RINGTONE_TYPE, defaultRingtoneType);
// For small icons, it's only allowed resource media types
assert(AwesomeStringUtils.isNullOrEmpty(icon) ||
AwesomeBitmapUtils().getMediaSource(icon!) == MediaSource.Resource);
}