EmpireNullableDoubleProperty class Null safety

An EmpireProperty with similar characteristics of dart double objects

The underlying value can be null.

You can perform most arithmetic operator on this (+, -, /, *). If the underlying value of this is null and an arithmetic operator is called on this, it will throw a EmpirePropertyNullValueException.

Unary operators are not supported (++, --, +=, -=, etc)

You can easily check for null by accessing the isNull or isNotNull properties.

When the value of this changes, it will send a EmpireStateChanged event by default. This includes automatically triggering a UI rebuild.

Example

late final EmpireNullableDoubleProperty percentage;

percentage = createNullableDoubleProperty();

if (percentage.isNull)
{
  print("I'm Null");
}

Other Usages Examples


late final EmpireNullableDoubleProperty percentage;

percentage = createNullableDoubleProperty();

print('${percentage + 5.2}'); //throws EmpireNullValueException because no value has been set yet.

percentage(10.0)

print('${percentage - 0.5}'); //prints 9.5

Inheritance

Constructors

EmpireNullableDoubleProperty(double? value, EmpireViewModel viewModel, {String? propertyName})

Properties

hashCode int
The hash code for this object.
read-only, inherited
isNegative bool
Whether this number is negative.
read-only
isNotNull bool
read-only, inherited
isNull bool
read-only, inherited
originalValue double?
read-only, inherited
propertyName String?
read / write, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
value double?
read-only, inherited

Methods

call(double? value, {bool notifyChange = true}) → void
inherited
equals(dynamic other) bool
Checks if other is equal to the value of this EmpireProperty
inherited
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.
inherited
round() int?
Returns the integer closest to the double value.
roundToDouble() double?
Returns the integer double value closest to the double value.
set(double? value, {bool notifyChange = true}) double?
Updates the property value. Notifies any listeners to the change
inherited
setOriginalValueToCurrent() → void
Updates the original value to what the current value of this property is.
inherited
toInt() int?
Truncates the double value and returns the int
toString() String
A string representation of this object.
inherited

Operators

operator %(dynamic other) double
operator *(dynamic other) double
operator +(dynamic other) double
operator -(dynamic other) double
operator /(dynamic other) double
operator ==(dynamic other) bool
The equality operator.
inherited