Add annotation and fromJson and toJson methods to all classes in the file
Morteza-Rastgoo opened this issue · 0 comments
Morteza-Rastgoo commented
If there is more than a class in a file, the plugin fails to add methods to them.
@JsonSerializable()
class CurrenciesPairsResponse {
bool status;
String message;
DataBean data;
CurrenciesPairsResponse(this.status, this.message, this.data);
factory CurrenciesPairsResponse.fromJson(Map<String, dynamic> json) =>
_$CurrenciesPairsResponseFromJson(json);
Map<String, dynamic> toJson() => _$CurrenciesPairsResponseToJson(this);
}
@JsonSerializable()
class DataBean {
List<Currency> pairs;
List<Pair> favorites;
DataBean(this.pairs, this.favorites);
factory DataBean.fromJson(Map<String, dynamic> json) =>
_$DataBeanFromJson(json);
Map<String, dynamic> toJson() => _$DataBeanToJson(this);
}
@JsonSerializable()
class Currency {
int id;
String code;
String name;
int subUnit;
List<Pair> pairs;
Currency(this.id, this.code, this.name, this.subUnit, this.pairs);
factory Currency.fromJson(Map<String, dynamic> json) =>
_$CurrencyFromJson(json);
Map<String, dynamic> toJson() => _$CurrencyToJson(this);
}