Reputation: 1
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,
});
}
and my api schemas is;
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
}
]
and my error is " Unable to instantiate class 'ModelSubClass' with null named arguments [Symbol("createdDate"), Symbol("modifiedDate"), Symbol("deletedDate")]" how can i fix that, i tried a lot of things but non of worked. thanks for helping
i tried nullable value also i tried DateTime instead of String but it couldnt work.
Upvotes: 0
Views: 87
Reputation: 521
Removing final
keywords for ModelSubClass fields did the trick for me. Not sure why though, would appreciate some insights on this.
Upvotes: 0