JsonInteger class
A specialized JSON field for handling integer (whole number) values.
JsonInteger extends JsonField<int> to provide type-safe handling of integer values in JSON data. It supports parsing numeric strings to integers and ensures that integer fields always return a valid integer value.
Key Features:
- Parses numeric strings to integer values
- Defaults to
0when value is null - Type-safe integer operations
Usage Example:
final age = JsonInteger('age');
age.value = 25; // Direct integer
age.value = "30"; // String parsed to integer
print(age.value); // 30
age.value = "invalid"; // Sets rawValue to null (parse fails)
print(age.value); // 0 (default)
See also:
- JsonField for the base field implementation
- JsonDouble for decimal numbers
- JsonNumber for generic numeric values
Constructors
- JsonInteger(String fieldName)
- Creates a new JsonInteger field with the specified field name.
Properties
- error ↔ String?
-
An error message associated with this field, if any.
getter/setter pairinherited
- fieldName → String
-
The name of this field as it appears in JSON data.
finalinherited
- hasError → bool
-
Returns
trueif this field has an error message.no setterinherited - hashCode → int
-
Returns the hash code for this field.
no setterinherited
- hasInformation → bool
-
Returns
trueif this field has an informational message.no setterinherited - hasWarning → bool
-
Returns
trueif this field has a warning message.no setterinherited - information ↔ String?
-
An informational message associated with this field, if any.
getter/setter pairinherited
- isNotNull → bool
-
Returns
trueif the raw value of this field is notnull.no setterinherited - isNull → bool
-
Returns
trueif the raw value of this field isnull.no setterinherited - rawValue ↔ int?
-
The raw, unprocessed value stored in this field.
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value ↔ int
-
Returns the integer value of this field.
getter/setter pairoverride
- warning ↔ String?
-
A warning message associated with this field, if any.
getter/setter pairinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → int? -
Serializes the integer value to JSON format.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
Determines whether this field is equal to another object.
inherited