fromMap method

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

Creates a NotificationAndroidCrontab instance from a map of data.

Implementation

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

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

  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 = AwesomeDateUtils.parseStringToDate(schedule);
      if (scheduleDate != null) {
        _preciseSchedules!.add(scheduleDate);
      }
    }
  }
  validate();
  return this;
}