read<T> static method

T? read<T>(
  1. String key, {
  2. T? defaultValue,
})

Reads a value, returning defaultValue when storage is unavailable.

Implementation

static T? read<T>(String key, {T? defaultValue}) {
  final Box<dynamic>? box = _box;
  if (box == null || !box.isOpen) return defaultValue;
  final dynamic value = box.get(key, defaultValue: defaultValue);
  return value is T ? value : defaultValue;
}