setCustomValue<T> method
Sets a value of custom type T
and notifies all active listeners that
there's a new value for the key
.
Requires an implementation of a PreferenceAdapter for the type T
. For
an example of a custom adapter, see the source code for setString and
StringAdapter.
Returns true
if a value
was successfully set for the key
, otherwise
returns false
.
Implementation
Future<bool> setCustomValue<T>(
String key,
T value, {
required PreferenceAdapter<T> adapter,
}) {
assert(
// ignore: invalid_use_of_internal_member
key != Preference.$$_getKeysKey,
// ignore: invalid_use_of_internal_member
'"${Preference.$$_getKeysKey}" is a reserved key.',
);
return _updateAndNotify(key, adapter.setValue(_preferences, key, value));
}