CurrentViewModel class abstract

A ViewModel is an abstraction of the view it is bound to and represents the current state of the data in your model.

This is where any logic that manipulates your model should be. An CurrentComponent and it's accompanying state always has access to it's view model via the viewModel property.

Update events are automatically emitted whenever the value of an CurrentProperty is changed. The CurrentState the ViewModel is bound to will update itself each time an CurrentProperty value is changed and call the states build function, updating the UI.

Inheritance

Constructors

CurrentViewModel()

Properties

activeTasks List
no setterinherited
assignedTo int?
The state identifier that the view model is currently assigned to
no setterinherited
assignedToState bool
Whether the view model has already been assigned to a state
no setterinherited
busy bool
Whether the view model is currently busy performing a long running task. Can be used by the UI to show a loading indicator or prevent user interaction.
no setterinherited
currentBindings Iterable<CurrentViewModelBinding>
Provides a list of helper bindings that should attach after the view model has assigned itself to all currentProps.
no setterinherited
currentProps Iterable<CurrentProperty>
Provides a list of CurrentProperty fields in the CurrentStateViewModel.
no setterinherited
disposed bool
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
isDirty bool
Whether any of the properties defined in currentProps have a value that is different from their original value.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addAnyErrorEventListener(void onError(ErrorEvent event), {void onInternalError(Object error, StackTrace stackTrace)?}) StreamSubscription<ErrorEvent>
Adds an event handler for all ErrorEvent values
inherited
addAnyStateChangedListener(void onStateChanged(CurrentStateChanged event), {bool filter(CurrentStateChanged event)?, String? propertyName}) StreamSubscription<CurrentStateChanged>
Adds an event handler for all CurrentStateChanged events.
inherited
addBusyStatusChangedListener(void onChanged(BusyStatusChanged event), {dynamic busyTaskKey}) StreamSubscription
Subscribes to changes in the busy status of the view model.
inherited
addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
addOnErrorEventListener<T extends ErrorEvent>(void onError(T event), {void onInternalError(Object error, StackTrace stackTrace)?}) StreamSubscription<T>
Adds an event handler which gets executed each time notifyError is called.
inherited
addStateChangedListener<T extends CurrentStateChanged>(void onStateChanged(T event), {bool filter(T event)?, String? propertyName}) StreamSubscription<T>
Adds an event handler which gets executed each time an event of type T is added to the state stream.
inherited
assignTo(int widgetHash) → void
Creates associates the view model with a specific state via the states hash code.
inherited
cancelSubscription(StreamSubscription? subscription) Future<void>
Cancels the subscription. The subscriber will stop receiving events
inherited
dispose() → void
See disposeViewModel.
override
disposeViewModel() → void
Closes the state and error streams and removes any listeners associated with those streams.
inherited
doAsync<T>(Future<T> work(), {dynamic busyTaskKey}) Future<T>
Executes a long running task asynchronously.
inherited
isTaskInProgress(dynamic busyTaskKey) bool
Checks if the view model is busy working on a specific task.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyChange(CurrentStateChanged event) → void
Inform the bound state that the state of the UI needs to be updated with a single event.
inherited
notifyChanges(List<CurrentStateChanged> events) → void
Inform the bound state that the state of the UI needs to be updated.
inherited
notifyError(ErrorEvent event) → void
Inform the bound state that an error has occurred.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
releaseFrom(int widgetHash) → void
Releases the current state assignment when it matches the provided state identifier.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
resetAll() → void
Resets the value of all properties defined in the currentProps list to their original value.
inherited
setBusy({dynamic busyTaskKey}) → void
Sets the busy status to true
inherited
setBusyStatus({required bool isBusy, dynamic busyTaskKey}) → void
Explicitly updates the current busy status of the view model.
inherited
setMultiple(List<Map<CurrentProperty, dynamic>> setters) → void
Set multiple CurrentProperty values, but only trigger a single state change
inherited
setNotBusy({dynamic busyTaskKey}) → void
Sets the busy status to false
inherited
toString() String
A string representation of this object.
inherited

Operators

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