EventualNotifier<T> class

Extends EventualValue, so that subscribed Widgets can rebuild upon changes on the current value, error events or loading status

Inheritance
Mixed in types

Constructors

EventualNotifier([T initialValue])
Initializes the state with no value by default. If an argument is passed, the argument is set as the initial value.

Properties

error String
Syntactic sugar for setError(message)
write-only, inherited
errorMessage String
Returns the last error message defined
read-only, inherited
hasError bool
Returns true if an error message is currently set
read-only, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
hasListeners bool
Whether any listeners are currently registered. [...]
@protected, read-only, inherited
hasValue bool
Returns true if a valid value is registered and no error has cleared it
read-only, inherited
isFresh bool
Returns true only if a valid value was set less than N seconds ago
read-only, inherited
isLoading bool
Returns true if the loading flag is currently active
read-only, inherited
isLoadingFresh bool
Returns true if setToLoading() was recently called (by default, 10 seconds). Returns false if setToLoading() was called more than X seconds ago or the value is simply not "loading".
read-only, inherited
lastError DateTime
Returns the timestamp when the last error was set
read-only, inherited
lastUpdated DateTime
Returns the last successful update
read-only, inherited
loading bool
Sets or unsets the loading flag.
write-only, inherited
loadingMessage String
Returns the optional loading message string
read / write, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
value ↔ T
Provides the current value, if there is any
read / write, inherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes. [...]
inherited
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener and removeListener will throw after the object is disposed). [...]
@mustCallSuper, inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
notifyChange() EventualNotifier<T>
Explicitly emits a change notification to the listeners
notifyListeners() → void
Call all the registered listeners. [...]
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes. [...]
inherited
setDefaultValue(T defaultValue) EventualNotifier<T>
Sets a default value only if the object has just been created and no updates have been performed on it. Use this method if you want to set a default value on an immutable EventualValue created elsewhere. This is the same as invoking final myValue = EventualValue<int>(defaultValue);. Returns this so further methods can be chained right after.
override
setError(String error, {bool keepPreviousValue = true}) EventualNotifier<T>
Sets the error message to the given value and toggles loading to false. Optionally, allows to keep the current value, even if there is an error. Returns itself so further methods can be chained right after.
override
setToLoading([String loadingMessage]) EventualNotifier<T>
Sets the loading flag to true, an optional loading message and clears the error status. Returns itself so further methods can be chained right after.
override
setValue(T newValue) EventualNotifier<T>
Sets the underlying value, clears the error status, tracks the update time and sets the loading flag to false. Returns this so further methods can be chained right after.
override
toString() String
A string representation of this object. [...]
inherited
withFreshnessTimeout(Duration duration) EventualNotifier<T>
By default isFresh returns false 10 seconds after the value is set. Alter the recency threshold with a new value. Returns itself so further methods can be chained right after.
override
withLoadingTimeout(Duration duration) EventualNotifier<T>
By default isLoadingFresh returns true 10 seconds after loading is set to true. This method alters the timeout threshold with a new value. Returns itself so further methods can be chained right after.
override

Operators

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