AppPreference<T> class

Available extensions

Constructors

AppPreference.customSerialized({required AppPreferenceAdapter adapter, required String key, required RawValueSerializer<T> serializer, required RawValueDeserializer<T> deserializer})
Create a new AppPreference instance with value type that not directly supported by adapter with custom serializer and deserializer. serializer and deserializer need to handle the null value properly, which might be returned by adapter.
AppPreference.direct({required AppPreferenceAdapter adapter, required String key, required T defaultValue})
Create a new AppPreference instance with value type that directly supported by adapter
AppPreference.memory(FutureOr<T> value, {String key = 'memory', AsyncValueSetter<T> onWrite = nopAsyncValueSetter})
Create a new AppPreference instance that cached in memory, could be used for testing.
AppPreference.serialized({required AppPreferenceAdapter adapter, required String key, required T defaultValue, required JsonSerializer<T> serializer, required JsonDeserializer<T> deserializer})
Create a new AppPreference instance with value type that not directly supported by adapter jsonSerializer and jsonDeserializer will be used to serialize and deserialize the value to/from Map<String, dynamic>, which later can be convert to/fom JSON string via jsonEncode and jsonDecode.

Properties

hashCode int
The hash code for this object.
no setterinherited
ready Future<void>
A future that resolves when the preference is ready to use.
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value ↔ T
The current value of the preference.
getter/setter pair
writeDone Future<void>
A future that resolves when the preference is written.
no setter

Methods

asStream() Stream<T>
Create a Stream that emits the current value and its future changes.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyWhen(Predict<T> predict, ValueListener<T> listener) → ReactionDisposer
listener will be notified when predicate returns true Subscription disposes itself after listener is called once.
subscribe(ValueListener<T> listener) → ReactionDisposer
Subscribe to value and its future changes. listener would be notified for current value
subscribeChanges(ValueListener<T> listener) → ReactionDisposer
Subscribe to value's future changes. listener will be notified for all value changed, but not the current value.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

logger → Logger
Logger that receives logs from all AppPreference instances.
no setter

Static Methods

onError(ErrorListener errorListener) StreamSubscription<LogRecord>
Subscribe to all errors from all AppPreference instances. Could be useful to bridge AppPreference errors to error reporting system if app isn't using Logger.
onLog(ValueListener<LogRecord> listener) StreamSubscription<LogRecord>
Subscribe to all logs from all AppPreference instances. Could be useful to bridge AppPreference logs to other logging system if app isn't using Logger.