get<T> static method
获取数据
Implementation
static T? get<T>(String key, {T from(Map map)?, T? defValue}) {
final read = GetStorage().read(key);
if (read == null) {
if (key != 'XSpKey.OssImageUrl')
XLog.d('没有查询到数据,key=$key');
return defValue;
}
if (read is Map) {
if (read is T) {
return read as T;
}
if (from == null) {
XLog.d('需要将 jsonMap 转为 对象 $T 的 from 函数');
}
return from?.call(read) ?? defValue;
}
if (read is List) {
XLog.e('需使用 getList 来获取List');
return null;
}
return read;
}