json_serializable.dart
json_serializable.dart copied to clipboard
Not generating code for the final fields and the getters
Minimum reproducible code:
@JsonSerializable()
class Foo {
final int a = 0;
int get b => 42;
}
Problem:
The generated code doesn't include any of the a
or b
field:
Foo _$FooFromJson(Map<String, dynamic> json) => Foo();
Map<String, dynamic> _$FooToJson(Foo instance) => <String, dynamic>{};
Is this an expected behavior?
Flutter version:
Flutter 2.12.0-4.1.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 680962aa75 (4 weeks ago) • 2022-03-16 13:46:03 -0700
Engine • revision e9f57b5d0f
Tools • Dart 2.17.0 (build 2.17.0-182.1.beta) • DevTools 2.11.1
Package version:
6.1.5
Here's the question on the StackOverflow