EmpireProperty<T> class Null safety

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 prevet 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, EmpireViewModel _viewModel, {String? propertyName})

Properties

hashCode int
The hash code for this object.
read-only, override
isNotNull bool
read-only
isNull bool
read-only
originalValue → T
read-only
propertyName String?
read / write
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
value → T
read-only, override

Methods

call(T value, {bool notifyChange = true}) → void
equals(dynamic other) bool
Checks if other is equal to the value of this EmpireProperty
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
reset({bool notifyChange = true}) → void
Resets the value to what it was initialized with.
set(T value, {bool notifyChange = true}) → 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.
toString() String
A string representation of this object.
override

Operators

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