read<T> method
Read data from the Backpack with a key
.
Implementation
T? read<T>(String key, {dynamic defaultValue}) {
if (!_values.containsKey(key)) {
if (defaultValue != null) return defaultValue;
return null;
}
dynamic value = _values[key];
if (T.toString() != 'dynamic' && (value is String)) {
dynamic nyJson = _NyJson.tryDecode(value);
if (nyJson != null) {
T model = dataToModel<T>(data: nyJson);
_values[key] = model;
return model;
}
}
return value;
}