read<T extends Object> method

  1. @nonVirtual
  2. @override
Future<T?> read<T extends Object>(
  1. Key key,
  2. Decoder<T?> decoder, [
  3. Options? options
])
override

Reads a value of any type from persistent storage.

Implementation

@nonVirtual
@override
Future<T?> read<T extends Object>(Key key, Decoder<T?> decoder,
    [Options? options]) {
  assert(_debugAssertNotDisposed());

  return useStorageWithHandlers(
    (s) => s.read(key, decoder, options),
    (value, _) {
      if (_isLogEnabled) {
        _publishLog(
            ReadValueSuccessEvent(KeyAndValue(key, value, T), options));
      }
    },
    (error, _) {
      if (_isLogEnabled) {
        _publishLog(ReadValueFailureEvent(key, T, error, options));
      }
    },
  );
}