You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code builds, but see the comment for which critical information has to be removed for said build to succeed:
classBase<T> {
constBase();
}
classBaseConverter<T> extendsJsonConverter<Base, Map<String, Object?>> {
constBaseConverter();
@overrideMap<String, Object?> toJson(Base object) => {};
@overrideBasefromJson(Map<String, Object?> json) =>Base();
}
@JsonSerializable()
classData<T> extendsBase<T> {
Data({
requiredthis.data,
requiredthis.name,
});
factoryData.fromJson(Map<String, dynamic> json) =>_$DataFromJson(json);
finalString name;
@BaseConverter()
// Ideally, this would be Base<T>, but defining it so breaks the buildfinalBase data;
Map<String, dynamic> toJson() =>_$DataToJson(this);
}
Changing final Base data to final Base<T> data results in this error:
[SEVERE] json_serializable on lib/src/data.dart:
Could not generate `fromJson` code for `data`.
To support the type `Base` you can:
* Use `JsonConverter`
https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonConverter-class.html
* Use `JsonKey` fields `fromJson` and `toJson`
https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/fromJson.html
https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/toJson.html
package:json_serializable_test/src/data.dart:30:17
╷
[line number] │ final Base<T> data;
This despite the fact that a JsonConverter is clearly being used.
For posterity, I originally reported this at rrousselGit/freezed#1074, and was (correctly, it seems) directed here.
The text was updated successfully, but these errors were encountered:
The following code builds, but see the comment for which critical information has to be removed for said build to succeed:
Changing
final Base data
tofinal Base<T> data
results in this error:This despite the fact that a
JsonConverter
is clearly being used.For posterity, I originally reported this at rrousselGit/freezed#1074, and was (correctly, it seems) directed here.
The text was updated successfully, but these errors were encountered: