JsonNumber class

A specialized JSON field for handling generic numeric values.

JsonNumber extends JsonField<num> to provide type-safe handling of numeric values that can be either integers or doubles. It's useful when you need to accept any numeric type without specifying whether it's an integer or floating-point number.

Key Features:

  • Accepts both int and double values (via num type)
  • Parses numeric strings to numbers
  • Defaults to 0 when value is null
  • Type-safe numeric operations

Usage Example:

final count = JsonNumber('count');
count.value = 42;        // Integer
count.value = 3.14;      // Double
count.value = "100";     // String parsed to number
print(count.value);      // 100

See also:

Inheritance

Constructors

JsonNumber(String fieldName)
Creates a new JsonNumber 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 true if this field has an error message.
no setterinherited
hashCode int
Returns the hash code for this field.
no setterinherited
hasInformation bool
Returns true if this field has an informational message.
no setterinherited
hasWarning bool
Returns true if 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 true if the raw value of this field is not null.
no setterinherited
isNull bool
Returns true if the raw value of this field is null.
no setterinherited
rawValue num?
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 num
Returns the numeric 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() num?
Serializes the numeric 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