We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
PerFieldToJson
super
// 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
dart run build_runner build -d
It will generate the foo.g.dart file. Within this file, you will find the following method:
// foo.g.dart file: ... @override FooQuery whereCategory({ Object? isEqualTo = _sentinel, Object? isNotEqualTo = _sentinel, // ... }) { return _$FooQuery( _collection, $referenceWithoutCursor: $referenceWithoutCursor.where( _$FooFieldMap['category']!, isEqualTo: isEqualTo != _sentinel ? _$FooPerFieldToJson.category(isEqualTo as String) // <-- Error : null, isNotEqualTo: isNotEqualTo != _sentinel ? _$FooPerFieldToJson.category(isNotEqualTo as String) // <-- Error : null, // ... ), $queryCursor: $queryCursor, ); } ...
The error occurs because the generated _$FooPerFieldToJson class only has the age field and not the category field:
_$FooPerFieldToJson
age
category
// foo.g.dart file: ... abstract class _$FooPerFieldToJson { // ignore: unused_element static Object? age(int instance) => instance; } ...
Flutter 3.23.0-0.1.pre • channel beta • https://github.com/flutter/flutter.git Framework • revision 2feea7a407 (6 weeks ago) • 2024-06-06 10:19:10 +0700 Engine • revision bb10c54666 Tools • Dart 3.5.0 (build 3.5.0-180.3.beta) • DevTools 2.36.0
build_runner: 2.4.11 json_serializable: 6.8.0 cloud_firestore_odm_generator: 1.0.0-dev.88
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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:
The text was updated successfully, but these errors were encountered: