removeIdFromAllLists method

void removeIdFromAllLists(
  1. String type,
  2. String id
)

Implementation

void removeIdFromAllLists(String type, String id) {
  _write(() {
    for (final key in _lists.keys) {
      final knownType = _listTypes[key];
      if (knownType != null && knownType != type) continue;
      final list = _lists[key]!;
      if (list.ids.contains(id)) {
        final newIds = list.ids.where((e) => e != id).toList();
        _lists[key] = list.copyWith(
          ids: List.unmodifiable(newIds),
          total: list.total != null ? list.total! - 1 : null,
        );
        _notifyList(key);
      }
    }
  });
}