class Model {
final List<ModelFeatures>? shipFeatures;
final List<ModelClass>? modelClass;
final List<ModelMedia>? shipMedias;
const Model({
this.modelClass;
});
}
class ModelClass {
final ModelSubClass subClass;
const ModelClass({
required this.subClass,
});
}
class ModelSubClass {
final String? id;
final String? name;
final String? type;
final String? createdDate;
final String? modifiedDate;
final String? deletedDate;
const ModelSubClass({
this.id,
this.name,
this.type,
this.createdDate,
this.modifiedDate,
this.deletedDate,
});
}
我的 API 模式是;
modelClass
[
nullable: true
{
technicalInformationId string($uuid)
subClass{
idstring($uuid) nullable: true
namestring nullable: true
typeShipTypeEnum string Enum:
createdDate string($date-time) nullable: true
modifiedDatestring($date-time) nullable: true
deletedDatestring($date-time) nullable: true
}
value string nullable: true
createdDatestring($date-time) nullable: true
modifiedDatestring($date-time) nullable: true
deletedDatestring($date-time) nullable: true
}
]
我的错误是“无法实例化类'ModelSubClass' 使用空命名参数 [Symbol("createdDate")、Symbol("modifiedDate")、Symbol("deletedDate")]" 我该如何解决这个问题,我尝试了很多方法,但没有成功。感谢您的帮助
我也尝试过可为空值 我尝试使用 DateTime 而不是 String 但它无法工作。
同样的错误。我比较了 api 和我的 dart 文件,但我无法修复