Schedule constructor

Schedule({
  1. dynamic seconds,
  2. dynamic minutes,
  3. dynamic hours,
  4. dynamic days,
  5. dynamic months,
  6. dynamic weekdays,
})

Implementation

factory Schedule({
  /// The seconds a Task should be started.
  /// Can be one of `int`, `List<int>` or `String` or `null` (= match all).
  dynamic seconds,

  /// The minutes a Task should be started.
  /// Can be one of `int`, `List<int>` or `String` or `null` (= match all).
  dynamic minutes,

  /// The hours a Task should be started.
  /// Can be one of `int`, `List<int>` or `String` or `null` (= match all).
  dynamic hours,

  /// The days a Task should be started.
  /// Can be one of `int`, `List<int>` or `String` or `null` (= match all).
  dynamic days,

  /// The months a Task should be started.
  /// Can be one of `int`, `List<int>` or `String` or `null` (= match all).
  dynamic months,

  /// The weekdays a Task should be started.
  /// Can be one of `int`, `List<int>` or `String` or `null` (= match all).
  dynamic weekdays,
}) {
  final parsedSeconds =
      parseConstraint(seconds)?.where((x) => x >= 0 && x <= 59).toList();
  final parsedMinutes =
      parseConstraint(minutes)?.where((x) => x >= 0 && x <= 59).toList();
  final parsedHours =
      parseConstraint(hours)?.where((x) => x >= 0 && x <= 23).toList();
  final parsedDays =
      parseConstraint(days)?.where((x) => x >= 1 && x <= 31).toList();
  final parsedMonths =
      parseConstraint(months)?.where((x) => x >= 1 && x <= 12).toList();
  final parsedWeekdays = parseConstraint(weekdays)
      ?.where((x) => x >= 0 && x <= 7)
      .map((x) => x == 0 ? 7 : x)
      .toSet()
      .toList();
  return Schedule._(parsedSeconds, parsedMinutes, parsedHours, parsedDays,
      parsedMonths, parsedWeekdays);
}