fromMap method

  1. @override
NotificationAndroidCrontab? fromMap(
  1. Map<String, dynamic> mapData
)
override

Returns null if invalid mapData is provided

Implementation

@override
NotificationAndroidCrontab? fromMap(Map<String, dynamic> mapData) {
  super.fromMap(mapData);

  _crontabExpression = LocalAssertUtils.extractValue(
      NOTIFICATION_CRONTAB_EXPRESSION, mapData, String);
  _initialDateTime = LocalAssertUtils.extractValue(
      NOTIFICATION_INITIAL_DATE_TIME, mapData, DateTime);
  _expirationDateTime = LocalAssertUtils.extractValue(
      NOTIFICATION_EXPIRATION_DATE_TIME, mapData, DateTime);

  if (mapData[NOTIFICATION_PRECISE_SCHEDULES] is List) {
    List<String> schedules =
        List<String>.from(mapData[NOTIFICATION_PRECISE_SCHEDULES]);
    _preciseSchedules = [];

    for (String schedule in schedules) {
      DateTime? scheduleDate = LocalDateUtils.parseStringToDate(schedule);
      if (scheduleDate != null) {
        _preciseSchedules!.add(scheduleDate);
      }
    }
  }
  validate();
  return this;
}