-
-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toJson/fromJson is broken for nested lists of freezed objects #232
Comments
This is the "expected" behavior of You are supposed to either specify a |
Thanks for the quick explainer, adding that annotation fixed the test: @freezed
abstract class Todo with _$Todo {
// must be above factory method
@JsonSerializable(explicitToJson: true)
factory Todo(String name, bool checked) = _Todo;
factory Todo.fromJson(Map<String, dynamic> json) => _$TodoFromJson(json);
} Optionally creating build.yaml mentioned in #86 (only stumbled upon this now 😅 ) is a fix too: targets:
$default:
builders:
json_serializable:
options:
explicit_to_json: true Out of these two I think of going for |
Is it just me or is there still anyone for whom these solutions are not working?? |
My solutions:
|
Consider the following example:
Observe the following test fail:
with the following stacktrace:
This is because in
main.g.dart
we have:rather than:
The text was updated successfully, but these errors were encountered: