getList<T> static method

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

获取普通的List

Implementation

static Future<List<T>> getList<T>(String key, {List<T>? defValue}) async {
  if (_prefs == null) await getInstance();
  List<String> dataList =
      (_prefs?.getStringList(key) ?? defValue ?? []) as List<String>;
  return dataList.map((value) {
    T dataMap = json.decode(value) as T;
    return dataMap;
  }).toList();
}