getStringMap static method

Map getStringMap(
  1. String? key, {
  2. Map defValue = const {},
})

获取sp中key的map值

Implementation

static Map getStringMap(String? key, {Map defValue = const {}}) {
  if (key == null || key.isEmpty) {
    return defValue;
  }
  String? jsonString = _preferences.getString(key);
  if (jsonString == null) {
    return defValue;
  }
  return json.decode(jsonString);
}