getValue<T> method

T? getValue<T>(
  1. Object key
)

Implementation

T? getValue<T>(Object key) {
  Object? value = prefer.get(key.stringKey);
  if (value == null) return null;
  if (value is bool) return value.castTo();
  if (value is int) return value.castTo();
  if (value is double) return value.castTo();
  if (value is String) return value.castTo();
  if (value is List<String>) {
    if (T == List<String>) return value.castTo<List<String>>()?.castTo();
    if (T == List<bool>) return value.castTo<List<String>>()?.mapList((e) => bool.parse(e)).castTo();
    if (T == List<int>) return value.castTo<List<String>>()?.mapList((e) => int.parse(e)).castTo();
    if (T == List<double>) return value.castTo<List<String>>()?.mapList((e) => double.parse(e)).castTo();
  }
  error("Unsupport type, LocalStore.getValue:type=$T key=$key, value:$value");
}