JsonString class
A specialized JSON field for handling string (text) values.
JsonString extends JsonField<String> to provide type-safe handling of string values in JSON data. It ensures that string fields always return a valid string value, defaulting to an empty string when the underlying value is null.
Key Features:
- Always returns a string value (never null from the
valuegetter) - Defaults to empty string
""when the raw value is null - Preserves null values in JSON serialization when appropriate
Usage Example:
final name = JsonString('name');
name.value = 'John Doe';
print(name.value); // 'John Doe'
name.rawValue = null;
print(name.value); // '' (empty string, default)
print(name.toJson()); // null
See also:
- JsonField for the base field implementation
Constructors
- JsonString(String fieldName)
- Creates a new JsonString 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 ↔ String?
-
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 ↔ String
-
Returns the string 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(
) → String? -
Serializes the string 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