read method

  1. @override
Future<T?> read(
  1. String id, {
  2. String? userId,
})
override

Fetch a single item by its ID.

Implementation

@override
Future<T?> read(String id, {String? userId}) async {
  if (userId != null) {
    final found = _storage[userId]?[id];
    return found == null ? null : _fresh(found);
  }
  for (final byId in _storage.values) {
    final found = byId[id];
    if (found != null) return _fresh(found);
  }
  return null;
}