EmpireProperty<T> class

Contains any object that will notify any listeners when its value is changed.

Usually these are properties that are bound to a UI Widget so when the value changes, the UI is updated.

You optionally set the propertyName argument to conditionally perform logic when a specific property changes. You can access the propertyName in any event listener registered with the EmpireViewModel.addOnStateChangedListener function via the propertyName property on an EmpireStateChanged object.

If T is of type List or Map, use either EmpireListProperty or EmpireMapProperty. Not doing so will prevent the reset function from performing as expected.

An EmpireProperty is callable. Calling the property updates the value. However, there are two ways to update the value of an EmpireProperty:

Using set:

//initialize the property value to zero.
final age = createProperty<int>(0);

//update the property value to five.
age.set(5);

Calling the property:

//initialize the property value to zero.
final age = createProperty<int>(0);

//update the property value to five.
age(5);
Implemented types
Implementers

Constructors

EmpireProperty(T _value, {String? propertyName})

Properties

hashCode int
The hash code for this object.
no setteroverride
isNotNull bool
Returns true if the value of this is not null.
no setter
isNull bool
Returns true if the value of this is null.
no setter
originalValue → T
no setter
propertyName String?
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T
no setteroverride
viewModel EmpireViewModel
Returns the instance of the EmpireViewModel this property is associated with.
no setter

Methods

call(T value, {bool notifyChange = true, bool setAsOriginal = false}) → void
Updates the underlying value for this EmpireProperty.
equals(dynamic other) bool
Checks if other is equal to the value of this EmpireProperty
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset({bool notifyChange = true}) → void
Resets the value to the originalValue.
set(T value, {bool notifyChange = true, bool setAsOriginal = false}) → T
Updates the property value. Notifies any listeners to the change
setOriginalValueToCurrent() → void
Updates the original value to what the current value of this property is.
setViewModel(EmpireViewModel viewModel) → void
Links this EmpireProperty instance with an EmpireViewModel.
toString() String
A string representation of this object.
override

Operators

operator ==(dynamic other) bool
The equality operator.
override