getAll method

  1. @override
Future<Map<String, E>> getAll([
  1. Iterable<String>? allowList
])
override

Retrieves multiple objects from the container.

This method fetches objects from storage, optionally filtered by an allowList of keys. If no allowList is provided, all objects in the container are returned. Objects are deserialized and returned in a map with decoded keys.

Parameters:

  • allowList - Optional. A list of keys to retrieve. If provided, only objects with these keys are returned. If null or not provided, all objects in the container are returned. All keys must be valid.

Returns: A future that completes with a map of keys to objects. Keys are in their decoded form (without container prefix).

Throws:

See also:

  • get for retrieving a single object
  • getValues for getting objects as a list without keys
  • getKeys for getting just the keys

Implementation

@override
Future<Map<String, E>> getAll([Iterable<String>? allowList]) async {
  validateKeys(allowList);
  final keys = allowList?.map(encodeKey).toSet() ?? await getEncodedKeys();
  if (keys.isEmpty) return {};
  final Map<String, dynamic> allData = await backend.getAll(keys);
  return <String, E>{
    for (final MapEntry(:key, :value) in allData.entries) decodeKey(key): deserialize(value.toString()),
  };
}