saveData method
save data to shared Prefs this fun will check value and if its String it saves as String and you can pass any data type whithout any hussel. except for list
Implementation
@override
Future<bool> saveData(StorageData keyValue) async {
//This storage is not not secured storage
if (keyValue.provider != StorageProvider.sharedPref) return false;
if (_preferences == null) await _initPreferencesIfNeeded();
// if (keyValue.data == null) {
// throw Exception('Metadata cannot be null');
// }
// Iterate over the entries of the metadata map
keyValue.data.forEach((key, value) {
if (value is String) {
_preferences!.setString(key, value);
} else if (value is bool) {
_preferences!.setBool(key, value);
} else if (value is int) {
_preferences!.setInt(key, value);
} else if (value is double) {
_preferences!.setDouble(key, value);
} else if (value is List<String>) {
_preferences!.setStringList(key, value);
} else {
throw Exception('Unsupported value type');
}
});
return true;
}