toJson method

  1. @override
bool? toJson()
override

Serializes the boolean value to JSON format.

Returns the raw boolean value, which may be null if no value has been set. This allows the JSON representation to distinguish between an explicitly set false value and an unset (null) value.

Returns: The boolean value (true or false), or null if no value has been set.

Example:

final field = JsonBoolean('active');
print(field.toJson()); // null

field.value = false;
print(field.toJson()); // false

Implementation

@override
bool? toJson() {
  return rawValue;
}