getMap<T> static method

Future<T> getMap<T>(
  1. String key, {
  2. T? defValue,
})

获取Map类型缓存,内部类型未定义

Implementation

static Future<T> getMap<T>(String key, {T? defValue}) async {
  if (_prefs == null) await getInstance();
  String data = _prefs?.getString(key) ?? '';
  if (data.isNotEmpty) return json.decode(data) as T;
  return defValue ?? {} as T;
}