NotificationChannel constructor

NotificationChannel({
  1. required String? channelKey,
  2. required String? channelName,
  3. required String? channelDescription,
  4. String? channelGroupKey,
  5. bool? channelShowBadge,
  6. NotificationImportance? importance,
  7. bool? playSound,
  8. String? soundSource,
  9. DefaultRingtoneType? defaultRingtoneType,
  10. bool? enableVibration,
  11. Int64List? vibrationPattern,
  12. bool? enableLights,
  13. Color? ledColor,
  14. int? ledOnMs,
  15. int? ledOffMs,
  16. String? groupKey,
  17. GroupSort? groupSort,
  18. GroupAlertBehavior? groupAlertBehavior,
  19. String? icon,
  20. Color? defaultColor,
  21. bool? locked,
  22. bool? onlyAlertOnce,
  23. NotificationPrivacy? defaultPrivacy,
  24. 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);
}