value property

  1. @override
String get value
override

Returns the string value of this field.

If the underlying rawValue is null, this getter returns an empty string "" as a default value. This ensures that string fields always provide a valid string value when accessed, which prevents null reference errors in string operations.

Returns: The string value, or an empty string "" if rawValue is null.

Example:

final field = JsonString('name');
print(field.value); // '' (empty string, default)

field.value = 'John Doe';
print(field.value); // 'John Doe'

print(field.value.length); // Always safe, never null

Implementation

@override
String get value => rawValue ?? "";
set value (dynamic value)
inherited

Sets the value of this field.

The default implementation simply assigns the value to rawValue. Subclasses may override this to provide type conversion, parsing, or validation logic.

Parameters:

  • value: The value to set. The type and conversion behavior depend on the specific field subclass.

Implementation

set value(dynamic value) {
  rawValue = value;
}