setValue method
Stores the value
associated with the key
.
The valueType
must match the type of value
as follows:
- Value type "Bool" must be passed if the value is of type
bool
. - Value type "Double" must be passed if the value is of type
double
. - Value type "Int" must be passed if the value is of type
int
. - Value type "String" must be passed if the value is of type
String
. - Value type "StringList" must be passed if the value is of type
List<String>
.
Implementation
@override
Future<bool> setValue(String valueType, String key, Object value) async {
final int ret = using((Arena arena) {
final Pointer<Char> pKey = key.toNativeChar(allocator: arena);
switch (valueType) {
case 'Bool':
return tizen.preference_set_boolean(pKey, value as bool);
case 'Double':
return tizen.preference_set_double(pKey, value as double);
case 'Int':
return tizen.preference_set_int(pKey, value as int);
case 'String':
return tizen.preference_set_string(
pKey,
(value as String).toNativeChar(allocator: arena),
);
case 'StringList':
return tizen.preference_set_string(
pKey,
_joinStringList(value as List<String>)
.toNativeChar(allocator: arena),
);
default:
throw UnimplementedError('Not supported type: $valueType');
}
});
if (ret == 0) {
_preferences[key] = value;
return true;
}
return false;
}