JsonDouble class

A specialized JSON field for handling double-precision floating-point numbers.

JsonDouble extends JsonField<double> to provide type-safe handling of decimal numbers in JSON data. It supports parsing numeric strings and converting integers to doubles, ensuring flexible input handling while maintaining type safety.

Key Features:

  • Parses numeric strings to double values
  • Converts integers to doubles automatically
  • Defaults to 0.0 when value is null
  • Handles various input types with graceful fallback

Usage Example:

final price = JsonDouble('price');
price.value = 19.99;        // Direct double
price.value = 25;            // Integer converted to double
price.value = "29.99";       // String parsed to double
print(price.value);          // 29.99

price.value = "invalid";     // Sets rawValue to null (parse fails)
print(price.value);          // 0.0 (default)

See also:

Inheritance

Constructors

JsonDouble(String fieldName)
Creates a new JsonDouble 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 ↔ double?
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 ↔ double
Returns the double 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() → double?
Serializes the double 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