JsonBoolean class

A specialized JSON field for handling boolean (true/false) values.

JsonBoolean extends JsonField<bool> to provide type-safe handling of boolean values in JSON data. It ensures that boolean fields always return a valid boolean value, defaulting to false when the underlying value is null.

Key Features:

  • Always returns a boolean value (never null from the value getter)
  • Defaults to false when the raw value is null
  • Preserves null values in JSON serialization when appropriate

Usage Example:

final isActive = JsonBoolean('isActive');
isActive.value = true;
print(isActive.value); // true

isActive.rawValue = null;
print(isActive.value); // false (default)
print(isActive.toJson()); // null

See also:

  • JsonField for the base field implementation
Inheritance

Constructors

JsonBoolean(String fieldName)
Creates a new JsonBoolean 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 bool?
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 bool
Returns the boolean value of this field.
getter/setter pairinherited-setteroverride-getter
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() bool?
Serializes the boolean 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