无法使用空命名参数实例化类“ModelSubClass”[Symbol(“createdDate”),Symbol(“modifiedDate”),Symbol(“deletedDate”)]

问题描述 投票:0回答: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,
  });
}

我的 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 但它无法工作。

flutter dart model jsonmodel
1个回答
0
投票

同样的错误。我比较了 api 和我的 dart 文件,但我无法修复

© www.soinside.com 2019 - 2024. All rights reserved.