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,
})

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 = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_CHANNEL_KEY, channelKey, String);
  channelName = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_CHANNEL_NAME, channelName, String);
  channelDescription = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_CHANNEL_DESCRIPTION, channelDescription, String);
  channelShowBadge = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_CHANNEL_SHOW_BADGE, channelShowBadge, bool);

  channelGroupKey = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_CHANNEL_GROUP_KEY, channelGroupKey, String);

  importance = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_IMPORTANCE, importance, NotificationImportance);
  playSound = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_PLAY_SOUND, playSound, bool);
  criticalAlerts = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_CHANNEL_CRITICAL_ALERTS, criticalAlerts, bool);
  soundSource = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_SOUND_SOURCE, soundSource, String);
  enableVibration = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_ENABLE_VIBRATION, enableVibration, bool);
  vibrationPattern = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_VIBRATION_PATTERN, vibrationPattern, Int64List);
  enableLights = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_ENABLE_LIGHTS, enableLights, bool);
  ledColor = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_LED_COLOR, ledColor, Color);
  ledOnMs = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_LED_ON_MS, ledOnMs, int);
  ledOffMs = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_LED_OFF_MS, ledOffMs, int);
  groupKey = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_GROUP_KEY, groupKey, String);
  groupSort = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_GROUP_SORT, groupSort, GroupSort);
  groupAlertBehavior = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_GROUP_ALERT_BEHAVIOR,
      groupAlertBehavior,
      GroupAlertBehavior);
  icon =
      LocalAssertUtils.getValueOrDefault(NOTIFICATION_ICON, icon, String);
  defaultColor = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_DEFAULT_COLOR, defaultColor, Color);
  locked =
      LocalAssertUtils.getValueOrDefault(NOTIFICATION_LOCKED, locked, bool);
  onlyAlertOnce = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_ONLY_ALERT_ONCE, onlyAlertOnce, bool);
  defaultPrivacy = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_DEFAULT_PRIVACY, defaultPrivacy, NotificationPrivacy);
  defaultRingtoneType = LocalAssertUtils.getValueOrDefault(
      NOTIFICATION_DEFAULT_RINGTONE_TYPE,
      defaultRingtoneType,
      DefaultRingtoneType);

  // For small icons, it's only allowed resource media types
  assert(LocalStringUtils.isNullOrEmpty(icon) ||
      LocalBitmapUtils().getMediaSource(icon!) == MediaSource.Resource);
}