toEntity method
Convert this partial into a full entity.
Validates that all required (non-nullable) fields are present.
Throws StateError if any required field is null/missing. The error message should indicate which required fields are missing.
Example
final partial = $UserPartial(id: 1, name: 'Alice', email: null);
try {
final user = partial.toEntity();
} on StateError catch (e) {
// "Required field 'email' is null on UserPartial"
print(e.message);
}
Implementation
@override
$JsonValueRecord toEntity() {
// Basic required-field check: non-nullable fields must be present.
final String? idValue = id;
if (idValue == null) {
throw StateError('Missing required field: id');
}
return $JsonValueRecord(
id: idValue,
objectValue: objectValue,
stringValue: stringValue,
mapDynamic: mapDynamic,
mapObject: mapObject,
listDynamic: listDynamic,
listObject: listObject,
);
}