_InternalLinkedHashMap<String, dynamic>' 不是 'String' 类型的子类型
_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'
如果Flutter中有List,@JsonSerialization
会处理List映射吗?
@JsonSerializable()
class Content {
Content(this.contentItems);
@JsonKey(name: "content-items")
List<Movie> contentItems;
factory Content.fromJson(Map<String, dynamic> json) =>
_$ContentFromJson(json);
Map<String, dynamic> toJson() => _$ContentToJson(this);
}
上面的class需要我们手动将json转换成电影列表吗?
所有需要的方法和映射将由@JsonSerializable注解生成。我们必须提供问题中给出的 _$ContentFromJson(json) 和 _$ContentToJson(this)。
对我来说,这最初不起作用..
在生成 g.dart 文件后它也没有表现 properly.Then 在重新启动机器后我能够得到预期的结果。还不知道是什么导致了错误。
如果Flutter中有List,@JsonSerialization
会处理List映射吗?
@JsonSerializable()
class Content {
Content(this.contentItems);
@JsonKey(name: "content-items")
List<Movie> contentItems;
factory Content.fromJson(Map<String, dynamic> json) =>
_$ContentFromJson(json);
Map<String, dynamic> toJson() => _$ContentToJson(this);
}
上面的class需要我们手动将json转换成电影列表吗?
所有需要的方法和映射将由@JsonSerializable注解生成。我们必须提供问题中给出的 _$ContentFromJson(json) 和 _$ContentToJson(this)。
对我来说,这最初不起作用.. 在生成 g.dart 文件后它也没有表现 properly.Then 在重新启动机器后我能够得到预期的结果。还不知道是什么导致了错误。