CurrentProperty<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 CurrentStateViewModel.addStateChangedListener function via the propertyName property on an CurrentStateChanged object.
If T is of type List or Map, use either CurrentListProperty or CurrentMapProperty. Not doing so
will prevent the reset function from performing as expected.
An CurrentProperty is callable. Calling the property updates the value. However, there are three ways to update the value of an CurrentProperty:
Directly using value:
//initialize the property value to zero.
final age = CurrentProperty.integer();
//update the property value to five.
age.value = 5;
Using set:
//initialize the property value to zero.
final age = CurrentProperty.integer();
//update the property value to five.
age.set(5);
Calling the property:
//initialize the property value to zero.
final age = CurrentProperty.integer();
//update the property value to five.
age(5);
- Implemented types
-
- CurrentValue<
T>
- CurrentValue<
- Implementers
Constructors
- CurrentProperty(T _value, {String? propertyName, bool isPrimitiveType = false})
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- isDirty → bool
-
Returns true if the value of this CurrentProperty is different from the originalValue.
no setter
- isNotNull → bool
-
Returns true if the value of this CurrentProperty is not null.
no setter
- isNull → bool
-
Returns true if the value of this CurrentProperty is null.
no setter
- isPrimitiveType → bool
-
final
- originalValue → T
-
no setter
- propertyName ↔ String?
-
getter/setter pair
-
registeredBindings
→ Iterable<
CurrentViewModelBinding> -
Helper bindings registered directly against this property.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sourceHashCode → int
-
final
- value ↔ T
-
Returns the current value of this CurrentProperty.
Setting the value will update the value of this CurrentProperty and trigger a UI update if the new value is different from the current value.
If
Tis a reference type, setting the value to a new instance ofTwith the same properties as the current value will still trigger a UI update since the reference has changed.getter/setter pairoverride-getter - viewModel → CurrentStateViewModel
-
Returns the instance of the CurrentStateViewModel this
property is associated with.
no setter
Methods
-
call(
T value, {bool notifyChange = true, bool setAsOriginal = false}) → void -
Updates the underlying
valuefor this CurrentProperty. -
equals(
dynamic other) → bool -
Checks if
otheris equal to the value of this CurrentProperty. -
hasValueChanged(
T currentValue, T originalValue) → bool - Determines whether the current value differs from the original value.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerBinding(
CurrentViewModelBinding binding) → void - Registers a helper binding against this property.
-
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(
CurrentStateViewModel viewModel) → void - Links this CurrentProperty instance with an CurrentStateViewModel.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Methods
-
boolean(
{bool initialValue = false, String? propertyName}) → CurrentBoolProperty - Factory constructor for initializing a CurrentBoolProperty.
-
dateTime(
{DateTime? initialValue, String? propertyName}) → CurrentDateTimeProperty - Factory constructor for initializing a CurrentDateTimeProperty.
-
doubleProp(
{double initialValue = 0.0, String? propertyName}) → CurrentDoubleProperty - Factory constructor for initializing a CurrentDoubleProperty.
-
integer(
{int initialValue = 0, String? propertyName}) → CurrentIntProperty - Factory constructor for initializing a CurrentIntProperty.
-
list<
TItem> ({List< TItem> ? initialValue, String? propertyName}) → CurrentListProperty<TItem> - Factory constructor for initializing a CurrentListProperty.
-
map<
TKey, TValue> ({Map< TKey, TValue> ? initialValue, String? propertyName}) → CurrentMapProperty<TKey, TValue> - Factory constructor for initializing a CurrentMapProperty.
-
nullable<
TNullable> ({String? propertyName}) → CurrentProperty< TNullable?> - Factory constructor for initializing a CurrentProperty with a null value.
-
nullableBoolean(
{bool? initialValue, String? propertyName}) → CurrentNullableBoolProperty - Factory constructor for initializing a CurrentNullableBoolProperty.
-
nullableDateTime(
{DateTime? initialValue, String? propertyName}) → CurrentNullableDateTimeProperty - Factory constructor for initializing a CurrentNullableDateTimeProperty.
-
nullableDecimal(
{double? initialValue, String? propertyName}) → CurrentNullableDoubleProperty -
nullableDouble(
{double? initialValue, String? propertyName}) → CurrentNullableDoubleProperty - Factory constructor for initializing a CurrentNullableDoubleProperty.
-
nullableInteger(
{int? initialValue, String? propertyName}) → CurrentNullableIntProperty - Factory constructor for initializing a CurrentNullableIntProperty.
-
nullableString(
{String? initialValue, String? propertyName}) → CurrentNullableStringProperty - Factory constructor for initializing a CurrentNullableStringProperty.
-
string(
{String initialValue = '', String? propertyName}) → CurrentStringProperty - Factory constructor for initializing a CurrentStringProperty.