EmpireViewModel class Null safety
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 EmpireWidget 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 EmpireProperty is changed. The EmpireState the ViewModel is bound to will update itself each time an EmpireProperty value is changed and call the states build function, updating the UI.
Constructors
Properties
- activeTasks → List
-
read-only
- busy → bool
-
read-only
- hashCode → int
-
The hash code for this object.
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
addOnErrorEventListener(
dynamic onError(ErrorEvent event)) → StreamSubscription - Adds an event handler which gets executed each time notifyError is called.
-
addOnStateChangedListener(
dynamic onStateChanged(List< EmpireStateChanged> events)) → StreamSubscription - Adds an event handler which gets executed each time an EmpireProperty value is changed.
-
cancelSubscription(
StreamSubscription? subscription) → Future< void> - Cancels the subscription. The subscriber will stop receiving events
-
createBoolProperty(
bool value, {String? propertyName}) → EmpireBoolProperty - Short hand helper function for initializing an EmpireBoolProperty.
-
createDateTimeProperty(
DateTime value, {String? propertyname}) → EmpireDateTimeProperty - Short hand helper function for initializing an EmpireDateTimeProperty.
-
createDoubleProperty(
double value, {String? propertyName}) → EmpireDoubleProperty - Short hand helper function for initializing an EmpireDoubleProperty.
-
createEmptyListProperty<
T> ({String? propertyName}) → EmpireListProperty< T> - Short hand helper function for initializing an empty EmpireListProperty.
-
createEmptyMapProperty<
K, V> ({String? propertyName}) → EmpireMapProperty< K, V> - Short hand helper function for initializing an empty EmpireMapProperty.
-
createIntProperty(
int value, {String? propertyName}) → EmpireIntProperty - Short hand helper function for initializing an EmpireIntProperty.
-
createListProperty<
T> (List< T> values, {String? propertyName}) → EmpireListProperty<T> - Short hand helper function for initializing an EmpireListProperty.
-
createMapProperty<
K, V> (Map< K, V> values, {String? propertyName}) → EmpireMapProperty<K, V> - Short hand helper function for initializing an EmpireMapProperty.
-
createNullableBoolProperty(
{bool? value, String? propertyName}) → EmpireNullableBoolProperty - Short hand helper function for initializing an EmpireNullableBoolProperty.
-
createNullableDateTimeProperty(
{DateTime? value, String? propertyName}) → EmpireNullableDateTimeProperty - Short hand helper function for initializing an EmpireNullableDateTimeProperty.
-
createNullableDoubleProperty(
{double? value, String? propertyName}) → EmpireNullableDoubleProperty - Short hand helper function for initializing an EmpireNullableDoubleProperty.
-
createNullableIntProperty(
{int? value, String? propertyName}) → EmpireNullableIntProperty - Short hand helper function for initializing an EmpireNullableIntProperty.
-
createNullableStringProperty(
{String? value, String? propertyName}) → EmpireNullableStringProperty - Short hand helper function for initializing an EmpireNullableStringProperty.
-
createNullProperty<
T> ({String? propertyName}) → EmpireProperty< T?> - Short hand helper function for initializing an EmpireProperty with a null value.
-
createProperty<
T> (T value, {String? propertyName}) → EmpireProperty< T> - Short hand helper function for initializing an EmpireProperty.
-
createStringProperty(
String value, {String? propertyName}) → EmpireStringProperty - Short hand helper function for initializing an EmpireStringProperty.
-
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.
-
initProperties(
) → void - Initializes all EmpireProperty properties in the ViewModel.
-
isTaskInProgress(
dynamic busyTaskKey) → bool - Checks if the view model is busy working on a specific task.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited
-
notifyChanges(
List< EmpireStateChanged> events) → void - Inform the bound EmpireState that the state of the UI needs to be updated.
-
notifyError(
ErrorEvent event) → void - Inform the bound EmpireState that an error has occurred.
-
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< setters) → voidEmpireProperty, dynamic> > - Set multiple EmpireProperty 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