checkIfExceedsLimit method

Future<void> checkIfExceedsLimit()

Implementation

Future<void> checkIfExceedsLimit() async {
  int? limit = getLimit();

  if (limit == null) {
    return;
  }

  if (limit < 0) {
    return;
  }

  List<String> keys = [];

  keys.addAll(_all.keys.toList());

  for (String key in keys) {
    if (getLength() < limit) {
      return;
    }

    if (!(await _all[key]!.shouldDeleteByLimit())) {
      continue;
    }

    dynamic model = _all.remove(key);

    await removeModel(model.getId());
  }
}