toMap method

  1. @override
Map<String, dynamic> toMap()
override

Converts the NotificationAndroidCrontab instance to a map.

Implementation

@override
Map<String, dynamic> toMap() {
  Map<String, dynamic> dataMap = super.toMap()
    ..addAll({
      NOTIFICATION_CRONTAB_EXPRESSION: _crontabExpression,
      NOTIFICATION_INITIAL_DATE_TIME:
          AwesomeDateUtils.parseDateToString(_initialDateTime),
      NOTIFICATION_EXPIRATION_DATE_TIME:
          AwesomeDateUtils.parseDateToString(_expirationDateTime),
      NOTIFICATION_PRECISE_SCHEDULES: null
    });

  if (!AwesomeListUtils.isNullOrEmpty(_preciseSchedules)) {
    List<String> schedulesMap = [];

    for (DateTime schedule in _preciseSchedules!) {
      String? scheduleDate = AwesomeDateUtils.parseDateToString(schedule);
      if (scheduleDate != null) {
        schedulesMap.add(scheduleDate);
      }
    }
    dataMap[NOTIFICATION_PRECISE_SCHEDULES] = schedulesMap;
  }

  return dataMap;
}