get<S> method
Implementation
@override
Future<S?> get<S>(String key) async {
final box = await _box.future;
dynamic value = box.get(key);
if (value != null && value is! S && (value is String || value is Map)) {
if (PersistenceService.deserializers.containsKey(S)) {
final deserializer = PersistenceService.deserializers[S];
value = deserializer!(value);
}
}
assert(
value is S || value == null,
'the type you are trying to get is not the same as what you saved',
);
return value as S?;
}