I migrated to null safety, environment: sdk: ">=2.12.0 <3.0.0"
But my ImageModel
report error.
class ImageModel {
ImageModel({
this.total,
this.totalHits,
});
int total;
int totalHits;
factory ImageModel.fromJson(Map<String, dynamic> json) => ImageModel(
total: json["total"],
totalHits: json["totalHits"],
);
Map<String, dynamic> toJson() => {
"total": total,
"totalHits": totalHits,
};
}
Should I just add required
to this.total
and this.totalHits
as the vscode suggest?
But this.total
and this.totalHits
are always return from server json.