getAllInstances method

List<DateTime> getAllInstances({
  1. required DateTime start,
  2. DateTime? after,
  3. bool includeAfter = false,
  4. DateTime? before,
  5. bool includeBefore = false,
})

Implementation

List<DateTime> getAllInstances({
  required DateTime start,
  DateTime? after,
  bool includeAfter = false,
  DateTime? before,
  bool includeBefore = false,
}) {
  assert(start.isValidRruleDateTime);
  assert(after.isValidRruleDateTime);
  assert(before.isValidRruleDateTime);

  final key = CacheKey(
    start: start,
    after: after,
    includeAfter: includeAfter,
    before: before,
    includeBefore: includeBefore,
  );

  final fromCache = _cache.get(key);
  if (fromCache != null) return fromCache;

  final results = getInstances(
    start: start,
    after: after,
    includeAfter: includeAfter,
    before: before,
    includeBefore: includeBefore,
  ).toList(growable: false);

  if (shouldCacheResults) {
    _cache.add(key, results);
  }

  return results;
}