load static method
Implementation
static Future<dynamic> load(String name) async {
final SharedPreferences preferences = await SharedPreferences.getInstance();
final getList = await loadList();
List savedList = getList == null ? [] : json.decode(getList);
bool typeString = false, typeInt = false, typeBool = false, typeDouble = false;
savedList.where((val) => val['name'] == name).map((val) {
if (val['type'] == 'string') {
typeString = true;
} else if (val['type'] == 'int') {
typeInt = true;
} else if (val['type'] == 'bool') {
typeBool = true;
} else if (val['type'] == 'double') {
typeDouble = true;
}
}).toString();
if (typeString != false) {
return preferences.getString(name);
} else if (typeInt != false) {
return preferences.getInt(name);
} else if (typeBool != false) {
return preferences.getBool(name);
} else if (typeDouble != false) {
return preferences.getDouble(name);
} else {
return null;
}
}