// foo.dart file
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cloud_firestore_odm/cloud_firestore_odm.dart';
import 'package:json_annotation/json_annotation.dart';
part 'foo.g.dart';
@JsonSerializable(
createFieldMap: true,
createPerFieldToJson: true,
)
class Foo extends Bar {
final int age;
Foo(this.age) : super(category: 'male');
}
abstract class Bar {
final String category;
Bar({required this.category});
}
@Collection<Foo>('foo')
final fooRef = FooCollectionReference();
Run dart run build_runner build -d
It will generate the foo.g.dart file. Within this file, you will find the following method:
Minimal reproducible code:
Run
dart run build_runner build -d
It will generate the foo.g.dart file. Within this file, you will find the following method:
The error occurs because the generated
_$FooPerFieldToJson
class only has theage
field and not thecategory
field:Flutter version:
Package version: