'Json serialization for code generation not working?
I have cloned a project from github and it shows error in some file and i found it was for json serilizable
part 'upload_response.g.dart';//error here
@AccountIdConverter()
@MediaTypeConverter()
@IdConverter()
@JsonSerializable()
class UploadResponse with EquatableMixin {
final AccountId accountId;
final Id blobId;
final MediaType type;
final int size;
UploadResponse(this.accountId, this.blobId, this.type, this.size);
factory UploadResponse.fromJson(Map<String, dynamic> json) => _$UploadResponseFromJson(json); //error here
Map<String, dynamic> toJson() => _$UploadResponseToJson(this);//error here
@override
List<Object?> get props => [accountId, blobId, type, size];
}
extension UploadResponseExtension on UploadResponse {
Attachment toAttachmentFile(String nameFile, {MediaType? mediaType}) {
return Attachment(blobId: blobId, size: UnsignedInt(size), name: nameFile, type: mediaType ?? type);
}
}
i have run the command flutter pub run build_runner build and terminal shows files are generated,
but the error for the files are still
what can be the reason .
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|