getAll method
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:
- ArgumentError if any key in the allowList is invalid
See also:
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()),
};
}