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 CurrentWidget 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.

Constructors

CurrentViewModel()

Properties

activeTasks List
no setter
assignedTo int?
The CurrentWidget that the view model is currently assigned to
no setter
assignedToWidget bool
Whether the view model has already been assigned to a widget
no setter
busy bool
no setter
currentProps Iterable<CurrentProperty>
Provides a list of CurrentProperty fields in the CurrentViewModel.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addOnErrorEventListener(dynamic onError(ErrorEvent event)) StreamSubscription
Adds an event handler which gets executed each time notifyError is called.
addOnStateChangedListener(dynamic onStateChanged(List<CurrentStateChanged> events)) StreamSubscription
Adds an event handler which gets executed each time an CurrentProperty value is changed.
assignTo(int widgetHash) → void
Creates associates the view model with a specific CurrentWidget via the widgets hash code.
cancelSubscription(StreamSubscription? subscription) Future<void>
Cancels the subscription. The subscriber will stop receiving events
dispose() → void
Closes the state and error streams and removes any listeners associated with those streams
doAsync<T>(Future<T> work(), {dynamic busyTaskKey}) Future<T>
Executes a long running task asynchronously.
isTaskInProgress(dynamic busyTaskKey) bool
Checks if the view model is busy working on a specific task.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyChanges(List<CurrentStateChanged> events) → void
Inform the bound CurrentState that the state of the UI needs to be updated.
notifyError(ErrorEvent event) → void
Inform the bound CurrentState that an error has occurred.
resetAll() → void
Resets the value of all properties defined in the currentProps list to their original value.
setBusy({dynamic busyTaskKey}) → void
Sets the busy status to true
setBusyStatus({required bool isBusy, dynamic busyTaskKey}) → void
Explicitly updates the current busy status of the view model.
setMultiple(List<Map<CurrentProperty, dynamic>> setters) → void
Set multiple CurrentProperty values, but only trigger a single state change
setNotBusy({dynamic busyTaskKey}) → void
Sets the busy status to false
toString() String
A string representation of this object.
inherited

Operators

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