value property
Gets the value of the JSON object field.
Returns:
- An instance of
T
, or a new instance if the value is null.
Implementation
@override
T get value {
if (rawValue == null) {
return GetIt.instance.get<T>();
}
return rawValue!;
}
Sets the value of the JSON object field.
Parameters:
value
: The new value of the field.
Implementation
@override
set value(dynamic value) {
if (value == null) {
rawValue = null;
return;
}
if (value is T) {
rawValue = value;
return;
}
if (value is Map<String, dynamic>) {
final model = GetIt.instance.get<T>();
model.fromJSON(value);
rawValue = model;
}
}