setItem method
Set item to storage
Value can be either String, bool, int or double. For any other type, it will throw DirectusError.
Implementation
@override
Future<void> setItem(String key, Object value) async {
final instance = _instance ?? await SharedPreferences.getInstance();
if (value is String) {
await instance.setString(key, value);
} else if (value is bool) {
await instance.setBool(key, value);
} else if (value is int) {
await instance.setInt(key, value);
} else if (value is double) {
await instance.setDouble(key, value);
} else {
throw DirectusError(
message: 'You can only store strings, numbers and booleans.',
);
}
}