The base model generated through AWS Amplify Studio:
@immutable
class Patient extends Model {
static const classType = const _PatientModelType();
final String id;
final String? _name;
final String? _family_name;
final TemporalDate? _dob;
final Gender? _gender;
final double? _height_in_inches;
final List<Assessment>? _Assessments;
final TemporalDateTime? _createdAt;
final TemporalDateTime? _updatedAt;
...
const Patient._internal({required this.id, required name, required family_name, required dob, required gender, required height_in_inches, Assessments, createdAt, updatedAt}): _name = name, _family_name = family_name, _dob = dob, _gender = gender, _height_in_inches = height_in_inches, _Assessments = Assessments, _createdAt = createdAt, _updatedAt = updatedAt;
factory Patient({String? id, required String name, required String family_name, required TemporalDate dob, required Gender gender, required double height_in_inches, List<Assessment>? Assessments}) {
return Patient._internal(
id: id == null ? UUID.getUUID() : id,
name: name,
family_name: family_name,
dob: dob,
gender: gender,
height_in_inches: height_in_inches,
Assessments: Assessments != null ? List<Assessment>.unmodifiable(Assessments) : Assessments);
}
...
Patient.fromJson(Map<String, dynamic> json)
: id = json['id'],
_name = json['name'],
_family_name = json['family_name'],
_dob = json['dob'] != null ? TemporalDate.fromString(json['dob']) : null,
_gender = enumFromString<Gender>(json['gender'], Gender.values),
_height_in_inches = (json['height_in_inches'] as num?)?.toDouble(),
_Assessments = json['Assessments'] is List
? (json['Assessments'] as List)
.where((e) => e?['serializedData'] != null)
.map((e) => Assessment.fromJson(new Map<String, dynamic>.from(e['serializedData'])))
.toList()
: null,
_createdAt = json['createdAt'] != null ? TemporalDateTime.fromString(json['createdAt']) : null,
_updatedAt = json['updatedAt'] != null ? TemporalDateTime.fromString(json['updatedAt']) : null;
...
}
I want to create an extension class GaitPatient. But, I am running into this error,
I am currently looking at using Patient.fromJSON constructor, but a bit hesitant about using that because it doesn't seem to be the cleanest... what are my options here?