write method
Save data with custom key
Implementation
Future write(String key, dynamic data) async {
return SharedPreferences.getInstance().then((sharedPreferences) {
if (data is bool) {
sharedPreferences.setBool(key, data);
} else if (data is String) {
sharedPreferences.setString(key, data);
} else if (data is int) {
sharedPreferences.setInt(key, data);
} else if (data is double) {
sharedPreferences.setDouble(key, data);
} else if (data is List<String>) {
sharedPreferences.setStringList(key, data);
} else {
print('FlutterPlusUtils.write -> INVALID TYPE');
}
}).catchError((error) {
print('FlutterPlusUtils.write -> $error');
});
}