EmpireNullableIntProperty class Null safety
An EmpireProperty with similar characteristics of dart int 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 EmpireNullableIntProperty age;
age = createNullableIntProperty();
if (age.isNull)
{
print("I'm Null");
}
Other Usages Examples
late final EmpireNullableIntProperty age;
age = createNullableIntProperty();
print('${age + 5}'); //throws EmpireNullValueException because no value has been set yet.
age(10)
print('${age - 5}'); //prints 5
- Inheritance
-
- Object
- EmpireProperty<
int?> - EmpireNullableIntProperty
Constructors
- EmpireNullableIntProperty(int? value, EmpireViewModel viewModel, {String? propertyName})
Properties
- hashCode → int
-
The hash code for this object.
read-only, inherited
- isEven → bool
-
Returns true if the int value is even.
read-only
- isNegative → bool
-
Whether this number is negative.
read-only
- isNotNull → bool
-
read-only, inherited
- isNull → bool
-
read-only, inherited
- isOdd → bool
-
Returns true if the int value is odd
read-only
- originalValue → int?
-
read-only, inherited
- propertyName ↔ String?
-
read / write, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- value → int?
-
read-only, inherited
Methods
-
abs(
) → int? - Returns the absolute value of this integer.
-
call(
int? value, {bool notifyChange = true}) → void -
inherited
-
equals(
dynamic other) → bool -
Checks if
other
is equal to the value of this EmpirePropertyinherited -
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
-
set(
int? value, {bool notifyChange = true}) → int? -
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
-
toDouble(
) → double? - The int value as a double
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator %(
dynamic other) → int -
operator *(
dynamic other) → int -
operator +(
dynamic other) → int -
operator -(
dynamic other) → int -
operator /(
dynamic other) → int -
operator ==(
dynamic other) → bool -
The equality operator.
inherited