diff --git a/README.md b/README.md index 5633a8b..bbc6818 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,12 @@ The ODM allows data schemas to be defined which represent the data structure of - 🎯 Data selectors to help avoid unnecessary Widget rebuilds. - 💻 Full API code completion. +## Compatibility + +- **Freezed**: Compatible with Freezed 3.0.0 and above +- **Analyzer**: Supports analyzer 7.0.0 and above +- **Source Gen**: Compatible with source_gen 2.0.0 and above + ## Installation ### 1. Use a recent Dart version @@ -34,7 +40,7 @@ That is done by adding the following to your `pubspec.yaml`: ```yaml environment: - sdk: ">=2.18.0 <4.0.0" + sdk: ">=3.8.0 <4.0.0" ``` ### 2. FlutterFire Initialization @@ -104,6 +110,24 @@ class MyModel {...} Once installed, read the documentation on [defining models](./docs/defining-models.md). + +## Development +### Testing +To run tests, you should have chromedriver install on your system. +```shell +./scripts/run-tests.sh +``` +Note: make sure in `packages/cloud_firestore_odm_generator/pubspec.yaml` to replace +``` +cloud_firestore_odm: {VERSION} +``` +with +``` +cloud_firestore_odm: + path: ../cloud_firestore_odm +``` +This is required for the tests to run. Set back to correct version before deploying. + ## Issues and feedback Please file FlutterFire specific issues, bugs, or feature requests in our [issue tracker](https://github.com/firebaseextended/firestoreodm-flutter/issues/new). diff --git a/packages/cloud_firestore_odm/CHANGELOG.md b/packages/cloud_firestore_odm/CHANGELOG.md index aec44da..9fa6f9f 100644 --- a/packages/cloud_firestore_odm/CHANGELOG.md +++ b/packages/cloud_firestore_odm/CHANGELOG.md @@ -1,3 +1,15 @@ +## 1.3.0 +- **CHORE**: upgraded packages to support analyzer ^8 and min sdk to 3.8.0 + +## 1.2.0 +- **CHORE**: Update cloud_firestore to ^6.0.0 + +## 1.1.0 + +- **FIX**: Resolve compatibility issues with Freezed 3.0.0 and above +- **FEAT**: Support analyzer 7.0.0 and above +- **CHORE**: Update dependencies to latest versions + ## 1.0.0-dev.88 - **BREAKING**: Removes `set` methods from `FirestoreDocumentReference` to make way for generated methods diff --git a/packages/cloud_firestore_odm/README.md b/packages/cloud_firestore_odm/README.md index f3bf4c2..3ccd508 100755 --- a/packages/cloud_firestore_odm/README.md +++ b/packages/cloud_firestore_odm/README.md @@ -7,6 +7,12 @@ To learn more about Firebase Cloud Firestore, please visit the [Firebase website [![pub package](https://img.shields.io/pub/v/cloud_firestore_odm.svg)](https://pub.dev/packages/cloud_firestore_odm) +## Compatibility + +- **Freezed**: Compatible with Freezed 3.0.0 and above +- **Analyzer**: Supports analyzer 7.0.0 and above +- **Source Gen**: Compatible with source_gen 2.0.0 and above + ## Getting Started To get started with Cloud Firestore for Flutter, please [see the documentation](https://github.com/firebaseextended/firestoreodm-flutter/tree/main/docs). diff --git a/packages/cloud_firestore_odm/example/integration_test/cloud_firestore_odm_e2e_test.dart b/packages/cloud_firestore_odm/example/integration_test/cloud_firestore_odm_e2e_test.dart index 6b1642c..3875a50 100644 --- a/packages/cloud_firestore_odm/example/integration_test/cloud_firestore_odm_e2e_test.dart +++ b/packages/cloud_firestore_odm/example/integration_test/cloud_firestore_odm_e2e_test.dart @@ -9,9 +9,8 @@ import 'package:integration_test/integration_test.dart'; import 'collection_reference_test.dart' as collection_reference_test; import 'document_reference_test.dart' as document_reference_test; - import 'firebase_options.dart'; - +import 'freezed_test.dart' as freezed_test; import 'path_test.dart' as path_test; import 'query_reference_test.dart' as query_reference_test; @@ -32,5 +31,6 @@ void main() { // firestore_builder_test.main(); query_reference_test.main(); path_test.main(); + freezed_test.main(); }); } diff --git a/packages/cloud_firestore_odm/example/integration_test/collection_reference_test.dart b/packages/cloud_firestore_odm/example/integration_test/collection_reference_test.dart index 2d9ec22..82b77a0 100644 --- a/packages/cloud_firestore_odm/example/integration_test/collection_reference_test.dart +++ b/packages/cloud_firestore_odm/example/integration_test/collection_reference_test.dart @@ -49,16 +49,12 @@ void main() { expect(b.data?.id, '456'); }); - test( - 'When using @Id, set/update do not insert an "id" property in the document', - () async { + test('When using @Id, set/update do not insert an "id" property in the document', () async { final collection = await initializeTest(MovieCollectionReference()); await collection.doc('123').set(createMovie(title: 'a', id: '42')); - final snapshot = await FirebaseFirestore.instance - .doc(collection.doc('123').path) - .get(); + final snapshot = await FirebaseFirestore.instance.doc(collection.doc('123').path).get(); expect(snapshot.data()?.containsKey('id'), false); }); @@ -67,8 +63,7 @@ void main() { test('reference', () async { expect( MovieCollectionReference().reference, - isA>() - .having((e) => e.path, 'path', 'firestore-example-app'), + isA>().having((e) => e.path, 'path', 'firestore-example-app'), ); expect( @@ -137,14 +132,12 @@ void main() { expect( await stream.next, isA().having((e) => e.docs, 'doc', [ - isA() - .having((e) => e.data.title, 'data.title', 'title'), + isA().having((e) => e.data.title, 'data.title', 'title'), ]), ); }); - test('emits an error if decoding fails, but keeps listening to updates', - () async { + test('emits an error if decoding fails, but keeps listening to updates', () async { final collection = await initializeTest(MovieCollectionReference()); await FirebaseFirestore.instance @@ -185,8 +178,7 @@ void main() { }); group('doc', () { - test('generates a custom ID for documents if none is specified', - () async { + test('generates a custom ID for documents if none is specified', () async { final collection = await initializeTest(MovieCollectionReference()); final doc = collection.doc(); @@ -200,10 +192,7 @@ void main() { test('can specify a custom ID to obtain an existing doc', () async { final collection = await initializeTest(MovieCollectionReference()); - await FirebaseFirestore.instance - .collection('firestore-example-app') - .doc('123') - .set( + await FirebaseFirestore.instance.collection('firestore-example-app').doc('123').set( MovieCollectionReference.toFirestore( createMovie(title: 'title'), null, @@ -217,8 +206,7 @@ void main() { expect( await doc.get(), - isA() - .having((e) => e.data?.title, 'data.title', 'title'), + isA().having((e) => e.data?.title, 'data.title', 'title'), ); }); }); @@ -256,16 +244,14 @@ void main() { stream, emits( isA().having((e) => e.docs, 'doc', [ - isA() - .having((e) => e.data.title, 'data.title', 'Foo'), + isA().having((e) => e.data.title, 'data.title', 'Foo'), ]), ), ); expect( await newDoc.get(), - isA() - .having((e) => e.data?.title, 'data.title', 'Foo'), + isA().having((e) => e.data?.title, 'data.title', 'Foo'), ); }); @@ -282,10 +268,8 @@ void main() { expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'A'), - isA() - .having((d) => d.data.title, 'data.title', 'B'), + isA().having((d) => d.data.title, 'data.title', 'A'), + isA().having((d) => d.data.title, 'data.title', 'B'), ], ); }); @@ -299,16 +283,13 @@ void main() { final bSnap = await b.get(); - final querySnap = - await collection.orderByTitle(endAtDocument: bSnap).get(); + final querySnap = await collection.orderByTitle(endAtDocument: bSnap).get(); expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'A'), - isA() - .having((d) => d.data.title, 'data.title', 'B'), + isA().having((d) => d.data.title, 'data.title', 'A'), + isA().having((d) => d.data.title, 'data.title', 'B'), ], ); }); @@ -327,10 +308,8 @@ void main() { expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'A'), - isA() - .having((d) => d.data.title, 'data.title', 'B'), + isA().having((d) => d.data.title, 'data.title', 'A'), + isA().having((d) => d.data.title, 'data.title', 'B'), ], ); }); @@ -344,14 +323,12 @@ void main() { final bSnap = await b.get(); - final querySnap = - await collection.orderByTitle(endBeforeDocument: bSnap).get(); + final querySnap = await collection.orderByTitle(endBeforeDocument: bSnap).get(); expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'A'), + isA().having((d) => d.data.title, 'data.title', 'A'), ], ); }); @@ -455,20 +432,15 @@ void main() { ), ); - final querySnap = await collection - .whereGenre(arrayContains: 'bar') - .orderByTitle() - .get(); + final querySnap = await collection.whereGenre(arrayContains: 'bar').orderByTitle().get(); expect( querySnap.docs.map((e) => e.data.title), ['B', 'C'], ); - final querySnap2 = await collection - .whereTags(arrayContains: 'serious') - .orderByTitle() - .get(); + final querySnap2 = + await collection.whereTags(arrayContains: 'serious').orderByTitle().get(); expect( querySnap2.docs.map((e) => e.data.title), @@ -506,8 +478,7 @@ void main() { await collection.doc('B').set(createMovie(title: 'title')); await collection.doc('C').set(createMovie(title: 'title')); - final querySnap = - await collection.orderByDocumentId(startAt: 'B').get(); + final querySnap = await collection.orderByDocumentId(startAt: 'B').get(); expect( querySnap.docs, @@ -525,8 +496,7 @@ void main() { await collection.doc('B').set(createMovie(title: 'title')); await collection.doc('C').set(createMovie(title: 'title')); - final querySnap = - await collection.whereDocumentId(isEqualTo: 'B').get(); + final querySnap = await collection.whereDocumentId(isEqualTo: 'B').get(); expect( querySnap.docs, @@ -539,15 +509,11 @@ void main() { group('where', () { test('supports field renaming', () async { - final collection = - await initializeTest(AdvancedJsonCollectionReference()); + final collection = await initializeTest(AdvancedJsonCollectionReference()); - await collection - .add(AdvancedJson(firstName: 'John', lastName: 'Doe')); - await collection - .add(AdvancedJson(firstName: 'John', lastName: 'Smith')); - await collection - .add(AdvancedJson(firstName: 'Mike', lastName: 'Doe')); + await collection.add(AdvancedJson(firstName: 'John', lastName: 'Doe')); + await collection.add(AdvancedJson(firstName: 'John', lastName: 'Smith')); + await collection.add(AdvancedJson(firstName: 'Mike', lastName: 'Doe')); expect( await collection.reference @@ -589,16 +555,12 @@ void main() { group('orderBy', () { test('supports field renaming', () async { - final collection = - await initializeTest(AdvancedJsonCollectionReference()); + final collection = await initializeTest(AdvancedJsonCollectionReference()); await collection.add(AdvancedJson(firstName: 'A', lastName: 'A')); - await collection - .add(AdvancedJson(firstName: 'John', lastName: 'Doe')); - await collection - .add(AdvancedJson(firstName: 'John', lastName: 'Smith')); - await collection - .add(AdvancedJson(firstName: 'Mike', lastName: 'Doe')); + await collection.add(AdvancedJson(firstName: 'John', lastName: 'Doe')); + await collection.add(AdvancedJson(firstName: 'John', lastName: 'Smith')); + await collection.add(AdvancedJson(firstName: 'Mike', lastName: 'Doe')); expect( await collection.reference @@ -646,10 +608,8 @@ void main() { expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'B'), - isA() - .having((d) => d.data.title, 'data.title', 'C'), + isA().having((d) => d.data.title, 'data.title', 'B'), + isA().having((d) => d.data.title, 'data.title', 'C'), ], ); }, @@ -668,10 +628,8 @@ void main() { await collection.add(createMovie(title: 'C', likes: 1)); await collection.add(createMovie(title: 'C', likes: 2)); - final querySnap = await collection - .orderByTitle(startAt: 'B') - .orderByLikes(startAt: 2) - .get(); + final querySnap = + await collection.orderByTitle(startAt: 'B').orderByLikes(startAt: 2).get(); expect( querySnap.docs, @@ -700,16 +658,13 @@ void main() { final bSnap = await b.get(); - final querySnap = - await collection.orderByTitle(startAtDocument: bSnap).get(); + final querySnap = await collection.orderByTitle(startAtDocument: bSnap).get(); expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'B'), - isA() - .having((d) => d.data.title, 'data.title', 'C'), + isA().having((d) => d.data.title, 'data.title', 'B'), + isA().having((d) => d.data.title, 'data.title', 'C'), ], ); }); @@ -723,14 +678,12 @@ void main() { await collection.add(createMovie(title: 'B')); await collection.add(createMovie(title: 'C')); - final querySnap = - await collection.orderByTitle(startAfter: 'B').get(); + final querySnap = await collection.orderByTitle(startAfter: 'B').get(); expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'C'), + isA().having((d) => d.data.title, 'data.title', 'C'), ], ); }); @@ -744,14 +697,12 @@ void main() { final bSnap = await b.get(); - final querySnap = - await collection.orderByTitle(startAfterDocument: bSnap).get(); + final querySnap = await collection.orderByTitle(startAfterDocument: bSnap).get(); expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'C'), + isA().having((d) => d.data.title, 'data.title', 'C'), ], ); }); @@ -769,10 +720,8 @@ void main() { expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'A'), - isA() - .having((d) => d.data.title, 'data.title', 'B'), + isA().having((d) => d.data.title, 'data.title', 'A'), + isA().having((d) => d.data.title, 'data.title', 'B'), ], ); }); @@ -789,10 +738,8 @@ void main() { expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'B'), - isA() - .having((d) => d.data.title, 'data.title', 'C'), + isA().having((d) => d.data.title, 'data.title', 'B'), + isA().having((d) => d.data.title, 'data.title', 'C'), ], ); }); @@ -956,9 +903,7 @@ void main() { test('overrides ==', () { expect( MovieCollectionReference().doc('123').comments, - MovieCollectionReference(FirebaseFirestore.instance) - .doc('123') - .comments, + MovieCollectionReference(FirebaseFirestore.instance).doc('123').comments, ); expect( MovieCollectionReference().doc('123').comments, @@ -985,11 +930,10 @@ void main() { await collection.add(Enums(id: 'B', enumValue: TestEnum.two)); await collection.add(Enums(id: 'C', enumValue: TestEnum.two)); - final querySnap = - await collection.whereEnumValue(isEqualTo: TestEnum.two).get(); + final querySnap = await collection.whereEnumValue(isEqualTo: TestEnum.two).get(); expect( - querySnap.docs.map((e) => e.data.id), + (querySnap.docs.map((e) => e.data.id).toList()..sort()), ['B', 'C'], ); }); @@ -1001,12 +945,10 @@ void main() { await collection.add(Enums(id: 'B', nullableEnumValue: TestEnum.two)); await collection.add(Enums(id: 'C', nullableEnumValue: TestEnum.two)); - final querySnap = await collection - .whereNullableEnumValue(isEqualTo: TestEnum.two) - .get(); + final querySnap = await collection.whereNullableEnumValue(isEqualTo: TestEnum.two).get(); expect( - querySnap.docs.map((e) => e.data.id), + (querySnap.docs.map((e) => e.data.id).toList()..sort()), ['B', 'C'], ); }); @@ -1014,18 +956,14 @@ void main() { test('enumList', () async { final collection = await initializeTest(EnumsCollectionReference()); - await collection - .add(Enums(id: 'A', enumList: [TestEnum.one, TestEnum.three])); - await collection - .add(Enums(id: 'B', enumList: [TestEnum.two, TestEnum.three])); - await collection - .add(Enums(id: 'C', enumList: [TestEnum.two, TestEnum.three])); + await collection.add(Enums(id: 'A', enumList: [TestEnum.one, TestEnum.three])); + await collection.add(Enums(id: 'B', enumList: [TestEnum.two, TestEnum.three])); + await collection.add(Enums(id: 'C', enumList: [TestEnum.two, TestEnum.three])); - final querySnap = - await collection.whereEnumList(arrayContains: TestEnum.two).get(); + final querySnap = await collection.whereEnumList(arrayContains: TestEnum.two).get(); expect( - querySnap.docs.map((e) => e.data.id), + (querySnap.docs.map((e) => e.data.id).toList()..sort()), ['B', 'C'], ); }); @@ -1043,12 +981,10 @@ void main() { Enums(id: 'C', nullableEnumList: [TestEnum.two, TestEnum.three]), ); - final querySnap = await collection - .whereNullableEnumList(arrayContains: TestEnum.two) - .get(); + final querySnap = await collection.whereNullableEnumList(arrayContains: TestEnum.two).get(); expect( - querySnap.docs.map((e) => e.data.id), + (querySnap.docs.map((e) => e.data.id).toList()..sort()), ['B', 'C'], ); }); diff --git a/packages/cloud_firestore_odm/example/integration_test/common.dart b/packages/cloud_firestore_odm/example/integration_test/common.dart index c033ef9..be16607 100644 --- a/packages/cloud_firestore_odm/example/integration_test/common.dart +++ b/packages/cloud_firestore_odm/example/integration_test/common.dart @@ -9,8 +9,7 @@ import 'package:cloud_firestore_odm_example/movie.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:mockito/mockito.dart'; -Future - initializeTest>( +Future initializeTest>( T ref, ) async { final snapshot = await ref.reference.get(); diff --git a/packages/cloud_firestore_odm/example/integration_test/document_reference_test.dart b/packages/cloud_firestore_odm/example/integration_test/document_reference_test.dart index 465faaf..c034769 100644 --- a/packages/cloud_firestore_odm/example/integration_test/document_reference_test.dart +++ b/packages/cloud_firestore_odm/example/integration_test/document_reference_test.dart @@ -35,19 +35,13 @@ void main() { await collection.doc('123').set(createMovie(title: 'title')); - expect( - await collection.doc('123').get().then((e) => e.exists), - true, - ); + expect(await collection.doc('123').get().then((e) => e.exists), true); await FirebaseFirestore.instance.runTransaction((transaction) async { collection.doc('123').transactionDelete(transaction); }); - expect( - await collection.doc('123').get().then((e) => e.exists), - false, - ); + expect(await collection.doc('123').get().then((e) => e.exists), false); }); test('batch', () async { @@ -86,11 +80,7 @@ void main() { collection.doc(movieToSet).get().then((e) => e.data), collection.doc(movieToDelete).get().then((e) => e.exists), ]), - [ - updatedTitle, - isA().having((e) => e.title, newTitle, newTitle), - false, - ], + [updatedTitle, isA().having((e) => e.title, newTitle, newTitle), false], ); }); @@ -99,24 +89,21 @@ void main() { await collection.doc('123').set(createMovie(title: 'title')); - expect( - await collection.doc('123').get().then((e) => e.exists), - true, - ); + expect(await collection.doc('123').get().then((e) => e.exists), true); await collection.doc('123').delete(); - expect( - await collection.doc('123').get().then((e) => e.exists), - false, - ); + expect(await collection.doc('123').get().then((e) => e.exists), false); }); test('reference', () async { expect( MovieCollectionReference().doc('123').reference, - isA>() - .having((e) => e.path, 'path', 'firestore-example-app/123'), + isA>().having( + (e) => e.path, + 'path', + 'firestore-example-app/123', + ), ); expect( @@ -137,16 +124,10 @@ void main() { await collection.doc('123').get(); expect( - await collection - .doc('123') - .get(const GetOptions(source: Source.cache)), + await collection.doc('123').get(const GetOptions(source: Source.cache)), isA() .having((e) => e.data?.title, 'data.title', 'title') - .having( - (e) => e.metadata.isFromCache, - 'metadata.isFromCache', - true, - ), + .having((e) => e.metadata.isFromCache, 'metadata.isFromCache', true), ); }); }); @@ -172,8 +153,7 @@ void main() { expect( await stream.next, - isA() - .having((e) => e.exists, 'exists', false), + isA().having((e) => e.exists, 'exists', false), ); await collection.doc('123').set(createMovie(title: 'title')); @@ -191,7 +171,9 @@ void main() { test('allows modifying a single property of an object', () async { final ref = await initializeTest(moviesRef); - await ref.doc('123').set( + await ref + .doc('123') + .set( Movie( genre: [], likes: 42, @@ -248,17 +230,12 @@ void main() { ); await FirebaseFirestore.instance.runTransaction((transaction) async { - ref.doc('123').transactionSet( - transaction, - createMovie(title: 'Foo'), - ); + ref.doc('123').transactionSet(transaction, createMovie(title: 'Foo')); }); expect( await ref.doc('123').get().then((e) => e.data), - isA() - .having((e) => e.rated, 'rated', '') - .having((e) => e.title, 'title', 'Foo'), + isA().having((e) => e.rated, 'rated', '').having((e) => e.title, 'title', 'Foo'), ); }); }); @@ -286,12 +263,9 @@ void main() { ); }); - test('asserts that we cannot specify both FieldValue and normal value', - () async { + test('asserts that we cannot specify both FieldValue and normal value', () async { expect( - () => moviesRef - .doc('123') - .update(likes: 10, likesFieldValue: FieldValue.increment(10)), + () => moviesRef.doc('123').update(likes: 10, likesFieldValue: FieldValue.increment(10)), throwsAssertionError, ); }); @@ -299,7 +273,9 @@ void main() { test('allows modifying only one property of an object', () async { final ref = await initializeTest(moviesRef); - await ref.doc('123').set( + await ref + .doc('123') + .set( Movie( genre: [], likes: 42, @@ -324,9 +300,7 @@ void main() { .having((e) => e.year, 'year', 0), ); - await ref.doc('123').update( - genre: ['genre'], - ); + await ref.doc('123').update(genre: ['genre']); expect( await ref.doc('123').get().then((e) => e.data), @@ -344,7 +318,9 @@ void main() { test('can set a property to null', () async { final ref = await initializeTest(moviesRef); - await ref.doc('123').set( + await ref + .doc('123') + .set( Movie( genre: [], likes: 42, @@ -369,7 +345,9 @@ void main() { .having((e) => e.year, 'year', 0), ); - await ref.doc('123').update( + await ref + .doc('123') + .update( // ignore: avoid_redundant_argument_values, false positive genre: null, ); @@ -408,59 +386,40 @@ void main() { await collection.doc('123').set(createMovie(title: 'Foo')); - expect( - await collection.doc().get().then((d) => d.exists), - false, - ); - expect( - await collection.doc('123').get().then((d) => d.exists), - true, - ); + expect(await collection.doc().get().then((d) => d.exists), false); + expect(await collection.doc('123').get().then((d) => d.exists), true); }); }); group('root document reference', () { - test( - 'can make fromJson optional if model is annotated by JsonSerializable', - () async { + test('can make fromJson optional if model is annotated by JsonSerializable', () async { final collection = await initializeTest(optionalJsonRef); await collection.doc('123').set(OptionalJson(42)); - expect( - await collection.doc('123').get().then((value) => value.data?.value), - 42, - ); + expect(await collection.doc('123').get().then((value) => value.data?.value), 42); }); test( - 'if fromJson/toJson are specified, use them even if the model is annotated by JsonSerializable', - () async { - final collection = await initializeTest(mixedJsonRef); + 'if fromJson/toJson are specified, use them even if the model is annotated by JsonSerializable', + () async { + final collection = await initializeTest(mixedJsonRef); - await collection.doc('123').set(MixedJson(42)); + await collection.doc('123').set(MixedJson(42)); - final rawSnapshot = await FirebaseFirestore.instance - .collection('root') - .doc('123') - .get(); + final rawSnapshot = await FirebaseFirestore.instance.collection('root').doc('123').get(); - expect(rawSnapshot.data(), {'foo': 42}); - expect( - await collection.doc('123').get().then((value) => value.data?.value), - 42, - ); - }); + expect(rawSnapshot.data(), {'foo': 42}); + expect(await collection.doc('123').get().then((value) => value.data?.value), 42); + }, + ); test('overrides ==', () { expect( MovieCollectionReference().doc('123'), MovieCollectionReference(FirebaseFirestore.instance).doc('123'), ); - expect( - MovieCollectionReference().doc('123'), - isNot(MovieCollectionReference().doc('456')), - ); + expect(MovieCollectionReference().doc('123'), isNot(MovieCollectionReference().doc('456'))); expect( MovieCollectionReference(customFirestore).doc('123'), @@ -477,10 +436,7 @@ void main() { test('overrides ==', () { expect( MovieCollectionReference().doc('123').comments.doc('123'), - MovieCollectionReference(FirebaseFirestore.instance) - .doc('123') - .comments - .doc('123'), + MovieCollectionReference(FirebaseFirestore.instance).doc('123').comments.doc('123'), ); expect( MovieCollectionReference().doc('123').comments.doc('123'), @@ -492,21 +448,12 @@ void main() { ); expect( - MovieCollectionReference(customFirestore) - .doc('123') - .comments - .doc('123'), + MovieCollectionReference(customFirestore).doc('123').comments.doc('123'), isNot(MovieCollectionReference().doc('123').comments.doc('123')), ); expect( - MovieCollectionReference(customFirestore) - .doc('123') - .comments - .doc('123'), - MovieCollectionReference(customFirestore) - .doc('123') - .comments - .doc('123'), + MovieCollectionReference(customFirestore).doc('123').comments.doc('123'), + MovieCollectionReference(customFirestore).doc('123').comments.doc('123'), ); }); }); diff --git a/packages/cloud_firestore_odm/example/integration_test/firestore_builder_test.dart b/packages/cloud_firestore_odm/example/integration_test/firestore_builder_test.dart index 0e83f66..9b6611e 100644 --- a/packages/cloud_firestore_odm/example/integration_test/firestore_builder_test.dart +++ b/packages/cloud_firestore_odm/example/integration_test/firestore_builder_test.dart @@ -23,8 +23,7 @@ void main() { return ListView( children: [ - for (final doc in snapshot.requireData.docs) - Text(doc.data.title), + for (final doc in snapshot.requireData.docs) Text(doc.data.title), ], ); }, @@ -49,7 +48,7 @@ void main() { ); } - group('$FirestoreBuilder', () { + group('FirestoreBuilder', () { testWidgets('listens to documents', (tester) async { final collection = await initializeTest(MovieCollectionReference()); @@ -69,8 +68,7 @@ void main() { expect(find.text('Foo'), findsOneWidget); }); - testWidgets('emits errored snapshot when failed to decode a value', - (tester) async { + testWidgets('emits errored snapshot when failed to decode a value', (tester) async { final collection = await initializeTest(MovieCollectionReference()); await FirebaseFirestore.instance @@ -146,8 +144,7 @@ void main() { expect(find.text('A'), findsOneWidget); expect(find.text('B'), findsOneWidget); }); - testWidgets( - 'does not go back to loading if rebuilding the widget with the same query', + testWidgets('does not go back to loading if rebuilding the widget with the same query', (tester) async { final collection = await initializeTest(MovieCollectionReference()); diff --git a/packages/cloud_firestore_odm/example/integration_test/freezed_test.dart b/packages/cloud_firestore_odm/example/integration_test/freezed_test.dart index 461202b..faed47d 100644 --- a/packages/cloud_firestore_odm/example/integration_test/freezed_test.dart +++ b/packages/cloud_firestore_odm/example/integration_test/freezed_test.dart @@ -2,12 +2,21 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore_odm_example/integration/freezed.dart'; +import 'package:firebase_core/firebase_core.dart'; import 'package:flutter_test/flutter_test.dart'; import 'common.dart'; +import 'firebase_options.dart'; void main() { + setUpAll(() async { + await Firebase.initializeApp( + options: DefaultFirebaseOptions.currentPlatform, + ); + FirebaseFirestore.instance.useFirestoreEmulator('localhost', 8080); + }); test('supports field renaming', () async { final collection = await initializeTest(PersonCollectionReference()); @@ -55,12 +64,13 @@ void main() { await aRef.update(firstName: 'A2', lastName: 'B2'); expect( - await aRef.reference - .withConverter>( - fromFirestore: (value, _) => value.data()!, - toFirestore: (value, _) => value, - ) - .get(), + (await aRef.reference + .withConverter>( + fromFirestore: (value, _) => value.data()!, + toFirestore: (value, _) => value, + ) + .get()) + .data(), { 'first_name': 'A2', 'LAST_NAME': 'B2', diff --git a/packages/cloud_firestore_odm/example/integration_test/path_test.dart b/packages/cloud_firestore_odm/example/integration_test/path_test.dart index cf4650f..fadcc03 100644 --- a/packages/cloud_firestore_odm/example/integration_test/path_test.dart +++ b/packages/cloud_firestore_odm/example/integration_test/path_test.dart @@ -21,8 +21,7 @@ void main() { final snapshot = await collection.get(); expect(snapshot.docs, [ - isA() - .having((e) => e.data.value, 'data.value', 42), + isA().having((e) => e.data.value, 'data.value', 42), ]); }); @@ -36,8 +35,7 @@ void main() { final snapshot = await collection.get(); expect(snapshot.docs, [ - isA() - .having((e) => e.data.value, 'data.value', 42), + isA().having((e) => e.data.value, 'data.value', 42), ]); }); }); @@ -53,15 +51,12 @@ void main() { final snapshot = await collection.get(); expect(snapshot.docs, [ - isA() - .having((e) => e.data.value, 'data.value', 42), + isA().having((e) => e.data.value, 'data.value', 42), ]); }); - test('can be manually specified through the Collection annotation', - () async { - final collection = - await initializeTest(rootRef.doc('123').thisIsACustomName); + test('can be manually specified through the Collection annotation', () async { + final collection = await initializeTest(rootRef.doc('123').thisIsACustomName); await FirebaseFirestore.instance .collection('root/123/custom-sub-name') @@ -70,18 +65,15 @@ void main() { final snapshot = await collection.get(); expect(snapshot.docs, [ - isA() - .having((e) => e.data.value, 'data.value', 42), + isA().having((e) => e.data.value, 'data.value', 42), ]); }); }); }); group('collection class prefix', () { - test('can be manually specified through the Collection annotation', - () async { - final collection = - await initializeTest(rootRef.doc('123').customClassPrefix); + test('can be manually specified through the Collection annotation', () async { + final collection = await initializeTest(rootRef.doc('123').customClassPrefix); await FirebaseFirestore.instance .collection('root/123/custom-class-prefix') @@ -90,8 +82,7 @@ void main() { final snapshot = await collection.get(); expect(snapshot.docs, [ - isA() - .having((e) => e.data?.value, 'data.value', 42), + isA().having((e) => e.data?.value, 'data.value', 42), ]); }); }); diff --git a/packages/cloud_firestore_odm/example/integration_test/query_reference_test.dart b/packages/cloud_firestore_odm/example/integration_test/query_reference_test.dart index 9426839..4f53142 100644 --- a/packages/cloud_firestore_odm/example/integration_test/query_reference_test.dart +++ b/packages/cloud_firestore_odm/example/integration_test/query_reference_test.dart @@ -2,15 +2,11 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'dart:typed_data'; - import 'package:cloud_firestore/cloud_firestore.dart'; -import 'package:cloud_firestore_odm_example/integration/named_query.dart'; import 'package:cloud_firestore_odm_example/integration/query.dart'; import 'package:cloud_firestore_odm_example/movie.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:http/http.dart' as http; import 'common.dart'; @@ -38,10 +34,7 @@ void main() { MovieCollectionReference().limit(1), MovieCollectionReference(FirebaseFirestore.instance).limit(1), ); - expect( - MovieCollectionReference().limit(1), - isNot(MovieCollectionReference().limit(2)), - ); + expect(MovieCollectionReference().limit(1), isNot(MovieCollectionReference().limit(2))); expect( MovieCollectionReference(customFirestore).limit(1), @@ -58,10 +51,7 @@ void main() { test('overrides ==', () { expect( MovieCollectionReference().doc('123').comments.limit(1), - MovieCollectionReference(FirebaseFirestore.instance) - .doc('123') - .comments - .limit(1), + MovieCollectionReference(FirebaseFirestore.instance).doc('123').comments.limit(1), ); expect( MovieCollectionReference().doc('123').comments.limit(1), @@ -73,21 +63,12 @@ void main() { ); expect( - MovieCollectionReference(customFirestore) - .doc('123') - .comments - .limit(1), + MovieCollectionReference(customFirestore).doc('123').comments.limit(1), isNot(MovieCollectionReference().doc('123').comments.limit(1)), ); expect( - MovieCollectionReference(customFirestore) - .doc('123') - .comments - .limit(1), - MovieCollectionReference(customFirestore) - .doc('123') - .comments - .limit(1), + MovieCollectionReference(customFirestore).doc('123').comments.limit(1), + MovieCollectionReference(customFirestore).doc('123').comments.limit(1), ); }); }); @@ -99,8 +80,7 @@ void main() { await ref.add(DurationQuery(const Duration(days: 2))); await ref.add(DurationQuery(const Duration(days: 3))); - final snapshot = - await ref.orderByDuration(startAt: const Duration(days: 2)).get(); + final snapshot = await ref.orderByDuration(startAt: const Duration(days: 2)).get(); expect(snapshot.docs.length, 2); @@ -130,9 +110,7 @@ void main() { await ref.add(TimestampQuery(Timestamp.fromDate(DateTime(2000)))); await ref.add(TimestampQuery(Timestamp.fromDate(DateTime(2010)))); - final snapshot = await ref - .orderByTime(startAt: Timestamp.fromDate(DateTime(2000))) - .get(); + final snapshot = await ref.orderByTime(startAt: Timestamp.fromDate(DateTime(2000))).get(); expect(snapshot.docs.length, 2); @@ -147,8 +125,7 @@ void main() { await ref.add(GeoPointQuery(const GeoPoint(20, 0))); await ref.add(GeoPointQuery(const GeoPoint(20, 0))); - final snapshot = - await ref.orderByPoint(startAt: const GeoPoint(20, 0)).get(); + final snapshot = await ref.orderByPoint(startAt: const GeoPoint(20, 0)).get(); expect(snapshot.docs.length, 2); @@ -161,15 +138,9 @@ void main() { () async { final ref = await initializeTest(documentReferenceRef); - await ref.add( - DocumentReferenceQuery(FirebaseFirestore.instance.doc('foo/a')), - ); - await ref.add( - DocumentReferenceQuery(FirebaseFirestore.instance.doc('foo/b')), - ); - await ref.add( - DocumentReferenceQuery(FirebaseFirestore.instance.doc('foo/c')), - ); + await ref.add(DocumentReferenceQuery(FirebaseFirestore.instance.doc('foo/a'))); + await ref.add(DocumentReferenceQuery(FirebaseFirestore.instance.doc('foo/b'))); + await ref.add(DocumentReferenceQuery(FirebaseFirestore.instance.doc('foo/c'))); final snapshot = await ref .orderByRef(startAt: FirebaseFirestore.instance.doc('foo/b')) @@ -177,46 +148,10 @@ void main() { expect(snapshot.docs.length, 2); - expect( - snapshot.docs[0].data.ref, - FirebaseFirestore.instance.doc('foo/b'), - ); - expect( - snapshot.docs[1].data.ref, - FirebaseFirestore.instance.doc('foo/c'), - ); + expect(snapshot.docs[0].data.ref, FirebaseFirestore.instance.doc('foo/b')); + expect(snapshot.docs[1].data.ref, FirebaseFirestore.instance.doc('foo/c')); }, skip: 'Blocked by FlutterFire support for querying document references', ); }); - - group('FirebaeFirestore.myCustomNamedQuery()', () { - Future loadBundleSetup() async { - // endpoint serves a bundle with 3 documents each containing - // a 'number' property that increments in value 1-3. - final url = Uri.https('api.rnfirebase.io', '/firestore/bundle-4'); - final response = await http.get(url); - final string = response.body; - return Uint8List.fromList(string.codeUnits); - } - - test('myCustomNamedQuery() successful', () async { - final buffer = await loadBundleSetup(); - final task = FirebaseFirestore.instance.loadBundle(buffer); - - // ensure the bundle has been completely cached - await task.stream.last; - - // namedQuery 'named-bundle-test' which returns a QuerySnaphot of the same 3 documents - // with 'number' property - final snapshot = await FirebaseFirestore.instance.namedBundleTest4Get( - options: const GetOptions(source: Source.cache), - ); - - expect( - snapshot.docs.map((document) => document.data.number), - everyElement(anyOf(1, 2, 3)), - ); - }); - }); } diff --git a/packages/cloud_firestore_odm/example/lib/integration.g.dart b/packages/cloud_firestore_odm/example/lib/integration.g.dart index 0ea7bee..d2e9237 100644 --- a/packages/cloud_firestore_odm/example/lib/integration.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint, type=warning +// ignore_for_file: type=lint part of 'integration.dart'; @@ -26,9 +26,8 @@ abstract class AdvancedJsonCollectionReference implements AdvancedJsonQuery, FirestoreCollectionReference { - factory AdvancedJsonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$AdvancedJsonCollectionReference; + factory AdvancedJsonCollectionReference([FirebaseFirestore? firestore]) = + _$AdvancedJsonCollectionReference; static AdvancedJson fromFirestore( DocumentSnapshot> snapshot, @@ -61,7 +60,9 @@ class _$AdvancedJsonCollectionReference extends _$AdvancedJsonQuery firestore ??= FirebaseFirestore.instance; return _$AdvancedJsonCollectionReference._( - firestore.collection('firestore-example-app/test/advanced').withConverter( + firestore + .collection('firestore-example-app/test/advanced') + .withConverter( fromFirestore: AdvancedJsonCollectionReference.fromFirestore, toFirestore: AdvancedJsonCollectionReference.toFirestore, ), @@ -84,9 +85,7 @@ class _$AdvancedJsonCollectionReference extends _$AdvancedJsonQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return AdvancedJsonDocumentReference( - reference.doc(id), - ); + return AdvancedJsonDocumentReference(reference.doc(id)); } @override @@ -107,11 +106,12 @@ class _$AdvancedJsonCollectionReference extends _$AdvancedJsonQuery int get hashCode => Object.hash(runtimeType, reference); } -abstract class AdvancedJsonDocumentReference extends FirestoreDocumentReference< - AdvancedJson, AdvancedJsonDocumentSnapshot> { +abstract class AdvancedJsonDocumentReference + extends + FirestoreDocumentReference { factory AdvancedJsonDocumentReference( - DocumentReference reference) = - _$AdvancedJsonDocumentReference; + DocumentReference reference, + ) = _$AdvancedJsonDocumentReference; DocumentReference get reference; @@ -208,9 +208,10 @@ abstract class AdvancedJsonDocumentReference extends FirestoreDocumentReference< }); } -class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< - AdvancedJson, - AdvancedJsonDocumentSnapshot> implements AdvancedJsonDocumentReference { +class _$AdvancedJsonDocumentReference + extends + FirestoreDocumentReference + implements AdvancedJsonDocumentReference { _$AdvancedJsonDocumentReference(this.reference); @override @@ -246,6 +247,7 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< ...model.toJson(), if (firstNameFieldValue != null) _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -268,11 +270,16 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< ...model.toJson(), if (firstNameFieldValue != null) _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -286,11 +293,16 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< ...model.toJson(), if (firstNameFieldValue != null) _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -309,13 +321,16 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< ); final json = { if (firstName != _sentinel) - _$AdvancedJsonFieldMap['firstName']!: - _$AdvancedJsonPerFieldToJson.firstName(firstName as String?), + _$AdvancedJsonFieldMap['firstName']!: _$AdvancedJsonPerFieldToJson + .firstName(firstName as String?), + if (firstNameFieldValue != null) _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$AdvancedJsonFieldMap['lastName']!: - _$AdvancedJsonPerFieldToJson.lastName(lastName as String?), + _$AdvancedJsonFieldMap['lastName']!: _$AdvancedJsonPerFieldToJson + .lastName(lastName as String?), + if (lastNameFieldValue != null) _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -340,13 +355,16 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< ); final json = { if (firstName != _sentinel) - _$AdvancedJsonFieldMap['firstName']!: - _$AdvancedJsonPerFieldToJson.firstName(firstName as String?), + _$AdvancedJsonFieldMap['firstName']!: _$AdvancedJsonPerFieldToJson + .firstName(firstName as String?), + if (firstNameFieldValue != null) _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$AdvancedJsonFieldMap['lastName']!: - _$AdvancedJsonPerFieldToJson.lastName(lastName as String?), + _$AdvancedJsonFieldMap['lastName']!: _$AdvancedJsonPerFieldToJson + .lastName(lastName as String?), + if (lastNameFieldValue != null) _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -371,13 +389,16 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< ); final json = { if (firstName != _sentinel) - _$AdvancedJsonFieldMap['firstName']!: - _$AdvancedJsonPerFieldToJson.firstName(firstName as String?), + _$AdvancedJsonFieldMap['firstName']!: _$AdvancedJsonPerFieldToJson + .firstName(firstName as String?), + if (firstNameFieldValue != null) _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$AdvancedJsonFieldMap['lastName']!: - _$AdvancedJsonPerFieldToJson.lastName(lastName as String?), + _$AdvancedJsonFieldMap['lastName']!: _$AdvancedJsonPerFieldToJson + .lastName(lastName as String?), + if (lastNameFieldValue != null) _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -551,17 +572,17 @@ class _$AdvancedJsonQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(AdvancedJsonQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + AdvancedJsonQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -618,7 +639,8 @@ class _$AdvancedJsonQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -650,7 +672,8 @@ class _$AdvancedJsonQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -684,20 +707,24 @@ class _$AdvancedJsonQuery ? _$AdvancedJsonPerFieldToJson.firstName(isLessThan as String?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$AdvancedJsonPerFieldToJson - .firstName(isLessThanOrEqualTo as String?) + ? _$AdvancedJsonPerFieldToJson.firstName( + isLessThanOrEqualTo as String?, + ) : null, isGreaterThan: isGreaterThan != null ? _$AdvancedJsonPerFieldToJson.firstName(isGreaterThan as String?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$AdvancedJsonPerFieldToJson - .firstName(isGreaterThanOrEqualTo as String?) + ? _$AdvancedJsonPerFieldToJson.firstName( + isGreaterThanOrEqualTo as String?, + ) : null, whereIn: whereIn?.map((e) => _$AdvancedJsonPerFieldToJson.firstName(e)), - whereNotIn: - whereNotIn?.map((e) => _$AdvancedJsonPerFieldToJson.firstName(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$AdvancedJsonPerFieldToJson.firstName(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -731,20 +758,24 @@ class _$AdvancedJsonQuery ? _$AdvancedJsonPerFieldToJson.lastName(isLessThan as String?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$AdvancedJsonPerFieldToJson - .lastName(isLessThanOrEqualTo as String?) + ? _$AdvancedJsonPerFieldToJson.lastName( + isLessThanOrEqualTo as String?, + ) : null, isGreaterThan: isGreaterThan != null ? _$AdvancedJsonPerFieldToJson.lastName(isGreaterThan as String?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$AdvancedJsonPerFieldToJson - .lastName(isGreaterThanOrEqualTo as String?) + ? _$AdvancedJsonPerFieldToJson.lastName( + isGreaterThanOrEqualTo as String?, + ) : null, whereIn: whereIn?.map((e) => _$AdvancedJsonPerFieldToJson.lastName(e)), - whereNotIn: - whereNotIn?.map((e) => _$AdvancedJsonPerFieldToJson.lastName(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$AdvancedJsonPerFieldToJson.lastName(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -765,8 +796,10 @@ class _$AdvancedJsonQuery AdvancedJsonDocumentSnapshot? endBeforeDocument, AdvancedJsonDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -838,8 +871,10 @@ class _$AdvancedJsonQuery AdvancedJsonDocumentSnapshot? endBeforeDocument, AdvancedJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -911,8 +946,10 @@ class _$AdvancedJsonQuery AdvancedJsonDocumentSnapshot? endBeforeDocument, AdvancedJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$AdvancedJsonFieldMap['firstName']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$AdvancedJsonFieldMap['firstName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -942,25 +979,37 @@ class _$AdvancedJsonQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$AdvancedJsonPerFieldToJson.firstName(startAt as String?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$AdvancedJsonPerFieldToJson.firstName(startAfter as String?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$AdvancedJsonPerFieldToJson.firstName(endAt as String?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$AdvancedJsonPerFieldToJson.firstName(endBefore as String?), + ], endBeforeDocumentSnapshot: null, ); } @@ -984,8 +1033,10 @@ class _$AdvancedJsonQuery AdvancedJsonDocumentSnapshot? endBeforeDocument, AdvancedJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$AdvancedJsonFieldMap['lastName']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$AdvancedJsonFieldMap['lastName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1015,25 +1066,37 @@ class _$AdvancedJsonQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$AdvancedJsonPerFieldToJson.lastName(startAt as String?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$AdvancedJsonPerFieldToJson.lastName(startAfter as String?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$AdvancedJsonPerFieldToJson.lastName(endAt as String?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$AdvancedJsonPerFieldToJson.lastName(endBefore as String?), + ], endBeforeDocumentSnapshot: null, ); } @@ -1065,45 +1128,37 @@ class AdvancedJsonDocumentSnapshot @override AdvancedJsonDocumentReference get reference { - return AdvancedJsonDocumentReference( - snapshot.reference, - ); + return AdvancedJsonDocumentReference(snapshot.reference); } @override final AdvancedJson? data; } -class AdvancedJsonQuerySnapshot extends FirestoreQuerySnapshot { - AdvancedJsonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class AdvancedJsonQuerySnapshot + extends + FirestoreQuerySnapshot< + AdvancedJson, + AdvancedJsonQueryDocumentSnapshot + > { + AdvancedJsonQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory AdvancedJsonQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, ) { - final docs = - snapshot.docs.map(AdvancedJsonQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(AdvancedJsonQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - AdvancedJsonDocumentSnapshot._, - ); + return _decodeDocumentChange(change, AdvancedJsonDocumentSnapshot._); }).toList(); - return AdvancedJsonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return AdvancedJsonQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, AdvancedJsonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -1147,8 +1202,10 @@ class AdvancedJsonQueryDocumentSnapshot abstract class _PrivateAdvancedJsonCollectionReference implements _PrivateAdvancedJsonQuery, - FirestoreCollectionReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonQuerySnapshot> { + FirestoreCollectionReference< + _PrivateAdvancedJson, + _PrivateAdvancedJsonQuerySnapshot + > { factory _PrivateAdvancedJsonCollectionReference([ FirebaseFirestore? firestore, ]) = _$_PrivateAdvancedJsonCollectionReference; @@ -1181,8 +1238,9 @@ abstract class _PrivateAdvancedJsonCollectionReference class _$_PrivateAdvancedJsonCollectionReference extends _$_PrivateAdvancedJsonQuery implements _PrivateAdvancedJsonCollectionReference { - factory _$_PrivateAdvancedJsonCollectionReference( - [FirebaseFirestore? firestore]) { + factory _$_PrivateAdvancedJsonCollectionReference([ + FirebaseFirestore? firestore, + ]) { firestore ??= FirebaseFirestore.instance; return _$_PrivateAdvancedJsonCollectionReference._( @@ -1212,14 +1270,13 @@ class _$_PrivateAdvancedJsonCollectionReference id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return _PrivateAdvancedJsonDocumentReference( - reference.doc(id), - ); + return _PrivateAdvancedJsonDocumentReference(reference.doc(id)); } @override Future<_PrivateAdvancedJsonDocumentReference> add( - _PrivateAdvancedJson value) { + _PrivateAdvancedJson value, + ) { return reference .add(value) .then((ref) => _PrivateAdvancedJsonDocumentReference(ref)); @@ -1237,11 +1294,14 @@ class _$_PrivateAdvancedJsonCollectionReference } abstract class _PrivateAdvancedJsonDocumentReference - extends FirestoreDocumentReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonDocumentSnapshot> { + extends + FirestoreDocumentReference< + _PrivateAdvancedJson, + _PrivateAdvancedJsonDocumentSnapshot + > { factory _PrivateAdvancedJsonDocumentReference( - DocumentReference<_PrivateAdvancedJson> reference) = - _$_PrivateAdvancedJsonDocumentReference; + DocumentReference<_PrivateAdvancedJson> reference, + ) = _$_PrivateAdvancedJsonDocumentReference; DocumentReference<_PrivateAdvancedJson> get reference; @@ -1339,8 +1399,11 @@ abstract class _PrivateAdvancedJsonDocumentReference } class _$_PrivateAdvancedJsonDocumentReference - extends FirestoreDocumentReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonDocumentSnapshot> + extends + FirestoreDocumentReference< + _PrivateAdvancedJson, + _PrivateAdvancedJsonDocumentSnapshot + > implements _PrivateAdvancedJsonDocumentReference { _$_PrivateAdvancedJsonDocumentReference(this.reference); @@ -1364,7 +1427,8 @@ class _$_PrivateAdvancedJsonDocumentReference @override Future<_PrivateAdvancedJsonDocumentSnapshot> transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction .get(reference) .then(_PrivateAdvancedJsonDocumentSnapshot._); @@ -1380,6 +1444,7 @@ class _$_PrivateAdvancedJsonDocumentReference ...model.toJson(), if (firstNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -1402,11 +1467,16 @@ class _$_PrivateAdvancedJsonDocumentReference ...model.toJson(), if (firstNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -1420,11 +1490,16 @@ class _$_PrivateAdvancedJsonDocumentReference ...model.toJson(), if (firstNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -1445,11 +1520,14 @@ class _$_PrivateAdvancedJsonDocumentReference if (firstName != _sentinel) _$PrivateAdvancedJsonFieldMap['firstName']!: _$PrivateAdvancedJsonPerFieldToJson.firstName(firstName as String?), + if (firstNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) _$PrivateAdvancedJsonFieldMap['lastName']!: _$PrivateAdvancedJsonPerFieldToJson.lastName(lastName as String?), + if (lastNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -1476,11 +1554,14 @@ class _$_PrivateAdvancedJsonDocumentReference if (firstName != _sentinel) _$PrivateAdvancedJsonFieldMap['firstName']!: _$PrivateAdvancedJsonPerFieldToJson.firstName(firstName as String?), + if (firstNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) _$PrivateAdvancedJsonFieldMap['lastName']!: _$PrivateAdvancedJsonPerFieldToJson.lastName(lastName as String?), + if (lastNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -1507,11 +1588,14 @@ class _$_PrivateAdvancedJsonDocumentReference if (firstName != _sentinel) _$PrivateAdvancedJsonFieldMap['firstName']!: _$PrivateAdvancedJsonPerFieldToJson.firstName(firstName as String?), + if (firstNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) _$PrivateAdvancedJsonFieldMap['lastName']!: _$PrivateAdvancedJsonPerFieldToJson.lastName(lastName as String?), + if (lastNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -1533,8 +1617,10 @@ class _$_PrivateAdvancedJsonDocumentReference abstract class _PrivateAdvancedJsonQuery implements - QueryReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonQuerySnapshot> { + QueryReference< + _PrivateAdvancedJson, + _PrivateAdvancedJsonQuerySnapshot + > { @override _PrivateAdvancedJsonQuery limit(int limit); @@ -1679,25 +1765,28 @@ abstract class _PrivateAdvancedJsonQuery }); } -class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonQuerySnapshot> implements _PrivateAdvancedJsonQuery { +class _$_PrivateAdvancedJsonQuery + extends + QueryReference<_PrivateAdvancedJson, _PrivateAdvancedJsonQuerySnapshot> + implements _PrivateAdvancedJsonQuery { _$_PrivateAdvancedJsonQuery( this._collection, { required Query<_PrivateAdvancedJson> $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override - Stream<_PrivateAdvancedJsonQuerySnapshot> snapshots( - [SnapshotOptions? options]) { - return reference - .snapshots() - .map(_PrivateAdvancedJsonQuerySnapshot._fromQuerySnapshot); + Stream<_PrivateAdvancedJsonQuerySnapshot> snapshots([ + SnapshotOptions? options, + ]) { + return reference.snapshots().map( + _PrivateAdvancedJsonQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -1754,7 +1843,8 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1786,7 +1876,8 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1811,34 +1902,43 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, $referenceWithoutCursor: $referenceWithoutCursor.where( _$PrivateAdvancedJsonFieldMap['firstName']!, isEqualTo: isEqualTo != _sentinel - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isEqualTo as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isEqualTo as String?, + ) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isNotEqualTo as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isNotEqualTo as String?, + ) : null, isLessThan: isLessThan != null - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isLessThan as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isLessThan as String?, + ) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isLessThanOrEqualTo as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isLessThanOrEqualTo as String?, + ) : null, isGreaterThan: isGreaterThan != null - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isGreaterThan as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isGreaterThan as String?, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isGreaterThanOrEqualTo as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isGreaterThanOrEqualTo as String?, + ) : null, - whereIn: whereIn - ?.map((e) => _$PrivateAdvancedJsonPerFieldToJson.firstName(e)), - whereNotIn: whereNotIn - ?.map((e) => _$PrivateAdvancedJsonPerFieldToJson.firstName(e)), - isNull: isNull ?? + whereIn: whereIn?.map( + (e) => _$PrivateAdvancedJsonPerFieldToJson.firstName(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$PrivateAdvancedJsonPerFieldToJson.firstName(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1866,30 +1966,38 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, ? _$PrivateAdvancedJsonPerFieldToJson.lastName(isEqualTo as String?) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isNotEqualTo as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isNotEqualTo as String?, + ) : null, isLessThan: isLessThan != null - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isLessThan as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isLessThan as String?, + ) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isLessThanOrEqualTo as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isLessThanOrEqualTo as String?, + ) : null, isGreaterThan: isGreaterThan != null - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isGreaterThan as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isGreaterThan as String?, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isGreaterThanOrEqualTo as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isGreaterThanOrEqualTo as String?, + ) : null, - whereIn: whereIn - ?.map((e) => _$PrivateAdvancedJsonPerFieldToJson.lastName(e)), - whereNotIn: whereNotIn - ?.map((e) => _$PrivateAdvancedJsonPerFieldToJson.lastName(e)), - isNull: isNull ?? + whereIn: whereIn?.map( + (e) => _$PrivateAdvancedJsonPerFieldToJson.lastName(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$PrivateAdvancedJsonPerFieldToJson.lastName(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1910,8 +2018,10 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1983,8 +2093,10 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2057,8 +2169,9 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, }) { final query = $referenceWithoutCursor.orderBy( - _$PrivateAdvancedJsonFieldMap['firstName']!, - descending: descending); + _$PrivateAdvancedJsonFieldMap['firstName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2088,25 +2201,37 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PrivateAdvancedJsonPerFieldToJson.firstName(startAt as String?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PrivateAdvancedJsonPerFieldToJson.firstName(startAfter as String?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PrivateAdvancedJsonPerFieldToJson.firstName(endAt as String?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PrivateAdvancedJsonPerFieldToJson.firstName(endBefore as String?), + ], endBeforeDocumentSnapshot: null, ); } @@ -2131,8 +2256,9 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, }) { final query = $referenceWithoutCursor.orderBy( - _$PrivateAdvancedJsonFieldMap['lastName']!, - descending: descending); + _$PrivateAdvancedJsonFieldMap['lastName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2162,25 +2288,37 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PrivateAdvancedJsonPerFieldToJson.lastName(startAt as String?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PrivateAdvancedJsonPerFieldToJson.lastName(startAfter as String?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PrivateAdvancedJsonPerFieldToJson.lastName(endAt as String?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PrivateAdvancedJsonPerFieldToJson.lastName(endBefore as String?), + ], endBeforeDocumentSnapshot: null, ); } @@ -2206,24 +2344,26 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, class _PrivateAdvancedJsonDocumentSnapshot extends FirestoreDocumentSnapshot<_PrivateAdvancedJson> { _PrivateAdvancedJsonDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final DocumentSnapshot<_PrivateAdvancedJson> snapshot; @override _PrivateAdvancedJsonDocumentReference get reference { - return _PrivateAdvancedJsonDocumentReference( - snapshot.reference, - ); + return _PrivateAdvancedJsonDocumentReference(snapshot.reference); } @override final _PrivateAdvancedJson? data; } -class _PrivateAdvancedJsonQuerySnapshot extends FirestoreQuerySnapshot< - _PrivateAdvancedJson, _PrivateAdvancedJsonQueryDocumentSnapshot> { +class _PrivateAdvancedJsonQuerySnapshot + extends + FirestoreQuerySnapshot< + _PrivateAdvancedJson, + _PrivateAdvancedJsonQueryDocumentSnapshot + > { _PrivateAdvancedJsonQuerySnapshot._( this.snapshot, this.docs, @@ -2233,8 +2373,9 @@ class _PrivateAdvancedJsonQuerySnapshot extends FirestoreQuerySnapshot< factory _PrivateAdvancedJsonQuerySnapshot._fromQuerySnapshot( QuerySnapshot<_PrivateAdvancedJson> snapshot, ) { - final docs = - snapshot.docs.map(_PrivateAdvancedJsonQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(_PrivateAdvancedJsonQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { return _decodeDocumentChange( @@ -2243,18 +2384,14 @@ class _PrivateAdvancedJsonQuerySnapshot extends FirestoreQuerySnapshot< ); }).toList(); - return _PrivateAdvancedJsonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return _PrivateAdvancedJsonQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange<_PrivateAdvancedJsonDocumentSnapshot> - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, _PrivateAdvancedJsonDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, + decodeDoc, ) { return FirestoreDocumentChange<_PrivateAdvancedJsonDocumentSnapshot>( type: docChange.type, @@ -2271,14 +2408,14 @@ class _PrivateAdvancedJsonQuerySnapshot extends FirestoreQuerySnapshot< @override final List> - docChanges; + docChanges; } class _PrivateAdvancedJsonQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot<_PrivateAdvancedJson> implements _PrivateAdvancedJsonDocumentSnapshot { _PrivateAdvancedJsonQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final QueryDocumentSnapshot<_PrivateAdvancedJson> snapshot; @@ -2299,9 +2436,8 @@ abstract class EmptyModelCollectionReference implements EmptyModelQuery, FirestoreCollectionReference { - factory EmptyModelCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$EmptyModelCollectionReference; + factory EmptyModelCollectionReference([FirebaseFirestore? firestore]) = + _$EmptyModelCollectionReference; static EmptyModel fromFirestore( DocumentSnapshot> snapshot, @@ -2334,16 +2470,17 @@ class _$EmptyModelCollectionReference extends _$EmptyModelQuery firestore ??= FirebaseFirestore.instance; return _$EmptyModelCollectionReference._( - firestore.collection('firestore-example-app/test/config').withConverter( + firestore + .collection('firestore-example-app/test/config') + .withConverter( fromFirestore: EmptyModelCollectionReference.fromFirestore, toFirestore: EmptyModelCollectionReference.toFirestore, ), ); } - _$EmptyModelCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$EmptyModelCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -2357,9 +2494,7 @@ class _$EmptyModelCollectionReference extends _$EmptyModelQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return EmptyModelDocumentReference( - reference.doc(id), - ); + return EmptyModelDocumentReference(reference.doc(id)); } @override @@ -2546,17 +2681,17 @@ class _$EmptyModelQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(EmptyModelQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + EmptyModelQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -2613,7 +2748,8 @@ class _$EmptyModelQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2645,7 +2781,8 @@ class _$EmptyModelQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2666,8 +2803,10 @@ class _$EmptyModelQuery EmptyModelDocumentSnapshot? endBeforeDocument, EmptyModelDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2739,8 +2878,10 @@ class _$EmptyModelQuery EmptyModelDocumentSnapshot? endBeforeDocument, EmptyModelDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2819,22 +2960,17 @@ class EmptyModelDocumentSnapshot extends FirestoreDocumentSnapshot { @override EmptyModelDocumentReference get reference { - return EmptyModelDocumentReference( - snapshot.reference, - ); + return EmptyModelDocumentReference(snapshot.reference); } @override final EmptyModel? data; } -class EmptyModelQuerySnapshot extends FirestoreQuerySnapshot { - EmptyModelQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class EmptyModelQuerySnapshot + extends + FirestoreQuerySnapshot { + EmptyModelQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory EmptyModelQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -2842,21 +2978,14 @@ class EmptyModelQuerySnapshot extends FirestoreQuerySnapshot - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, EmptyModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -2909,9 +3038,9 @@ Map _$EmptyModelToJson(EmptyModel instance) => {}; AdvancedJson _$AdvancedJsonFromJson(Map json) => AdvancedJson( - firstName: json['first_name'] as String?, - lastName: json['LAST_NAME'] as String?, - ); + firstName: json['first_name'] as String?, + lastName: json['LAST_NAME'] as String?, +); const _$AdvancedJsonFieldMap = { 'firstName': 'first_name', @@ -2952,8 +3081,8 @@ abstract class _$PrivateAdvancedJsonPerFieldToJson { } Map _$PrivateAdvancedJsonToJson( - _PrivateAdvancedJson instance) => - { - 'first_name': instance.firstName, - 'LAST_NAME': instance.lastName, - }; + _PrivateAdvancedJson instance, +) => { + 'first_name': instance.firstName, + 'LAST_NAME': instance.lastName, +}; diff --git a/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart b/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart index 6946dff..8b303b5 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart @@ -26,9 +26,8 @@ abstract class EnumsCollectionReference implements EnumsQuery, FirestoreCollectionReference { - factory EnumsCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$EnumsCollectionReference; + factory EnumsCollectionReference([FirebaseFirestore? firestore]) = + _$EnumsCollectionReference; static Enums fromFirestore( DocumentSnapshot> snapshot, @@ -37,10 +36,7 @@ abstract class EnumsCollectionReference return Enums.fromJson(snapshot.data()!); } - static Map toFirestore( - Enums value, - SetOptions? options, - ) { + static Map toFirestore(Enums value, SetOptions? options) { return value.toJson(); } @@ -61,16 +57,17 @@ class _$EnumsCollectionReference extends _$EnumsQuery firestore ??= FirebaseFirestore.instance; return _$EnumsCollectionReference._( - firestore.collection('firestore-example-app').withConverter( + firestore + .collection('firestore-example-app') + .withConverter( fromFirestore: EnumsCollectionReference.fromFirestore, toFirestore: EnumsCollectionReference.toFirestore, ), ); } - _$EnumsCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$EnumsCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -84,9 +81,7 @@ class _$EnumsCollectionReference extends _$EnumsQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return EnumsDocumentReference( - reference.doc(id), - ); + return EnumsDocumentReference(reference.doc(id)); } @override @@ -272,12 +267,16 @@ class _$EnumsDocumentReference final json = { ...model.toJson(), if (idFieldValue != null) _$EnumsFieldMap['id']!: idFieldValue, + if (enumValueFieldValue != null) _$EnumsFieldMap['enumValue']!: enumValueFieldValue, + if (nullableEnumValueFieldValue != null) _$EnumsFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + if (enumListFieldValue != null) _$EnumsFieldMap['enumList']!: enumListFieldValue, + if (nullableEnumListFieldValue != null) _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; @@ -302,17 +301,25 @@ class _$EnumsDocumentReference final json = { ...model.toJson(), if (idFieldValue != null) _$EnumsFieldMap['id']!: idFieldValue, + if (enumValueFieldValue != null) _$EnumsFieldMap['enumValue']!: enumValueFieldValue, + if (nullableEnumValueFieldValue != null) _$EnumsFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + if (enumListFieldValue != null) _$EnumsFieldMap['enumList']!: enumListFieldValue, + if (nullableEnumListFieldValue != null) _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -328,17 +335,25 @@ class _$EnumsDocumentReference final json = { ...model.toJson(), if (idFieldValue != null) _$EnumsFieldMap['id']!: idFieldValue, + if (enumValueFieldValue != null) _$EnumsFieldMap['enumValue']!: enumValueFieldValue, + if (nullableEnumValueFieldValue != null) _$EnumsFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + if (enumListFieldValue != null) _$EnumsFieldMap['enumList']!: enumListFieldValue, + if (nullableEnumListFieldValue != null) _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -376,25 +391,36 @@ class _$EnumsDocumentReference final json = { if (id != _sentinel) _$EnumsFieldMap['id']!: _$EnumsPerFieldToJson.id(id as String), + if (idFieldValue != null) _$EnumsFieldMap['id']!: idFieldValue, + if (enumValue != _sentinel) - _$EnumsFieldMap['enumValue']!: - _$EnumsPerFieldToJson.enumValue(enumValue as TestEnum), + _$EnumsFieldMap['enumValue']!: _$EnumsPerFieldToJson.enumValue( + enumValue as TestEnum, + ), + if (enumValueFieldValue != null) _$EnumsFieldMap['enumValue']!: enumValueFieldValue, + if (nullableEnumValue != _sentinel) _$EnumsFieldMap['nullableEnumValue']!: _$EnumsPerFieldToJson .nullableEnumValue(nullableEnumValue as TestEnum?), + if (nullableEnumValueFieldValue != null) _$EnumsFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + if (enumList != _sentinel) - _$EnumsFieldMap['enumList']!: - _$EnumsPerFieldToJson.enumList(enumList as List), + _$EnumsFieldMap['enumList']!: _$EnumsPerFieldToJson.enumList( + enumList as List, + ), + if (enumListFieldValue != null) _$EnumsFieldMap['enumList']!: enumListFieldValue, + if (nullableEnumList != _sentinel) _$EnumsFieldMap['nullableEnumList']!: _$EnumsPerFieldToJson .nullableEnumList(nullableEnumList as List?), + if (nullableEnumListFieldValue != null) _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; @@ -438,25 +464,36 @@ class _$EnumsDocumentReference final json = { if (id != _sentinel) _$EnumsFieldMap['id']!: _$EnumsPerFieldToJson.id(id as String), + if (idFieldValue != null) _$EnumsFieldMap['id']!: idFieldValue, + if (enumValue != _sentinel) - _$EnumsFieldMap['enumValue']!: - _$EnumsPerFieldToJson.enumValue(enumValue as TestEnum), + _$EnumsFieldMap['enumValue']!: _$EnumsPerFieldToJson.enumValue( + enumValue as TestEnum, + ), + if (enumValueFieldValue != null) _$EnumsFieldMap['enumValue']!: enumValueFieldValue, + if (nullableEnumValue != _sentinel) _$EnumsFieldMap['nullableEnumValue']!: _$EnumsPerFieldToJson .nullableEnumValue(nullableEnumValue as TestEnum?), + if (nullableEnumValueFieldValue != null) _$EnumsFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + if (enumList != _sentinel) - _$EnumsFieldMap['enumList']!: - _$EnumsPerFieldToJson.enumList(enumList as List), + _$EnumsFieldMap['enumList']!: _$EnumsPerFieldToJson.enumList( + enumList as List, + ), + if (enumListFieldValue != null) _$EnumsFieldMap['enumList']!: enumListFieldValue, + if (nullableEnumList != _sentinel) _$EnumsFieldMap['nullableEnumList']!: _$EnumsPerFieldToJson .nullableEnumList(nullableEnumList as List?), + if (nullableEnumListFieldValue != null) _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; @@ -500,25 +537,36 @@ class _$EnumsDocumentReference final json = { if (id != _sentinel) _$EnumsFieldMap['id']!: _$EnumsPerFieldToJson.id(id as String), + if (idFieldValue != null) _$EnumsFieldMap['id']!: idFieldValue, + if (enumValue != _sentinel) - _$EnumsFieldMap['enumValue']!: - _$EnumsPerFieldToJson.enumValue(enumValue as TestEnum), + _$EnumsFieldMap['enumValue']!: _$EnumsPerFieldToJson.enumValue( + enumValue as TestEnum, + ), + if (enumValueFieldValue != null) _$EnumsFieldMap['enumValue']!: enumValueFieldValue, + if (nullableEnumValue != _sentinel) _$EnumsFieldMap['nullableEnumValue']!: _$EnumsPerFieldToJson .nullableEnumValue(nullableEnumValue as TestEnum?), + if (nullableEnumValueFieldValue != null) _$EnumsFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + if (enumList != _sentinel) - _$EnumsFieldMap['enumList']!: - _$EnumsPerFieldToJson.enumList(enumList as List), + _$EnumsFieldMap['enumList']!: _$EnumsPerFieldToJson.enumList( + enumList as List, + ), + if (enumListFieldValue != null) _$EnumsFieldMap['enumList']!: enumListFieldValue, + if (nullableEnumList != _sentinel) _$EnumsFieldMap['nullableEnumList']!: _$EnumsPerFieldToJson .nullableEnumList(nullableEnumList as List?), + if (nullableEnumListFieldValue != null) _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; @@ -762,9 +810,9 @@ class _$EnumsQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -825,7 +873,8 @@ class _$EnumsQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -857,7 +906,8 @@ class _$EnumsQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -901,7 +951,8 @@ class _$EnumsQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$EnumsPerFieldToJson.id(e)), whereNotIn: whereNotIn?.map((e) => _$EnumsPerFieldToJson.id(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -941,12 +992,14 @@ class _$EnumsQuery extends QueryReference ? _$EnumsPerFieldToJson.enumValue(isGreaterThan as TestEnum) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .enumValue(isGreaterThanOrEqualTo as TestEnum) + ? _$EnumsPerFieldToJson.enumValue( + isGreaterThanOrEqualTo as TestEnum, + ) : null, whereIn: whereIn?.map((e) => _$EnumsPerFieldToJson.enumValue(e)), whereNotIn: whereNotIn?.map((e) => _$EnumsPerFieldToJson.enumValue(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -980,22 +1033,28 @@ class _$EnumsQuery extends QueryReference ? _$EnumsPerFieldToJson.nullableEnumValue(isLessThan as TestEnum?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .nullableEnumValue(isLessThanOrEqualTo as TestEnum?) + ? _$EnumsPerFieldToJson.nullableEnumValue( + isLessThanOrEqualTo as TestEnum?, + ) : null, isGreaterThan: isGreaterThan != null - ? _$EnumsPerFieldToJson - .nullableEnumValue(isGreaterThan as TestEnum?) + ? _$EnumsPerFieldToJson.nullableEnumValue( + isGreaterThan as TestEnum?, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .nullableEnumValue(isGreaterThanOrEqualTo as TestEnum?) + ? _$EnumsPerFieldToJson.nullableEnumValue( + isGreaterThanOrEqualTo as TestEnum?, + ) : null, - whereIn: - whereIn?.map((e) => _$EnumsPerFieldToJson.nullableEnumValue(e)), - whereNotIn: - whereNotIn?.map((e) => _$EnumsPerFieldToJson.nullableEnumValue(e)), - isNull: isNull ?? + whereIn: whereIn?.map( + (e) => _$EnumsPerFieldToJson.nullableEnumValue(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$EnumsPerFieldToJson.nullableEnumValue(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1029,26 +1088,29 @@ class _$EnumsQuery extends QueryReference ? _$EnumsPerFieldToJson.enumList(isLessThan as List) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .enumList(isLessThanOrEqualTo as List) + ? _$EnumsPerFieldToJson.enumList( + isLessThanOrEqualTo as List, + ) : null, isGreaterThan: isGreaterThan != null ? _$EnumsPerFieldToJson.enumList(isGreaterThan as List) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .enumList(isGreaterThanOrEqualTo as List) + ? _$EnumsPerFieldToJson.enumList( + isGreaterThanOrEqualTo as List, + ) : null, arrayContains: arrayContains != null ? (_$EnumsPerFieldToJson.enumList([arrayContains as TestEnum]) - as List?)! - .single + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$EnumsPerFieldToJson.enumList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1073,39 +1135,48 @@ class _$EnumsQuery extends QueryReference $referenceWithoutCursor: $referenceWithoutCursor.where( _$EnumsFieldMap['nullableEnumList']!, isEqualTo: isEqualTo != _sentinel - ? _$EnumsPerFieldToJson - .nullableEnumList(isEqualTo as List?) + ? _$EnumsPerFieldToJson.nullableEnumList( + isEqualTo as List?, + ) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$EnumsPerFieldToJson - .nullableEnumList(isNotEqualTo as List?) + ? _$EnumsPerFieldToJson.nullableEnumList( + isNotEqualTo as List?, + ) : null, isLessThan: isLessThan != null - ? _$EnumsPerFieldToJson - .nullableEnumList(isLessThan as List?) + ? _$EnumsPerFieldToJson.nullableEnumList( + isLessThan as List?, + ) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .nullableEnumList(isLessThanOrEqualTo as List?) + ? _$EnumsPerFieldToJson.nullableEnumList( + isLessThanOrEqualTo as List?, + ) : null, isGreaterThan: isGreaterThan != null - ? _$EnumsPerFieldToJson - .nullableEnumList(isGreaterThan as List?) + ? _$EnumsPerFieldToJson.nullableEnumList( + isGreaterThan as List?, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .nullableEnumList(isGreaterThanOrEqualTo as List?) + ? _$EnumsPerFieldToJson.nullableEnumList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null - ? (_$EnumsPerFieldToJson - .nullableEnumList([arrayContains as TestEnum]) as List?)! - .single + ? (_$EnumsPerFieldToJson.nullableEnumList([ + arrayContains as TestEnum, + ]) + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$EnumsPerFieldToJson.nullableEnumList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1126,8 +1197,10 @@ class _$EnumsQuery extends QueryReference EnumsDocumentSnapshot? endBeforeDocument, EnumsDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1199,8 +1272,10 @@ class _$EnumsQuery extends QueryReference EnumsDocumentSnapshot? endBeforeDocument, EnumsDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1272,8 +1347,10 @@ class _$EnumsQuery extends QueryReference EnumsDocumentSnapshot? endBeforeDocument, EnumsDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$EnumsFieldMap['id']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['id']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1303,25 +1380,37 @@ class _$EnumsQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.id(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.id(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.id(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.id(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -1345,8 +1434,10 @@ class _$EnumsQuery extends QueryReference EnumsDocumentSnapshot? endBeforeDocument, EnumsDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$EnumsFieldMap['enumValue']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['enumValue']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1376,25 +1467,37 @@ class _$EnumsQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.enumValue(startAt as TestEnum), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.enumValue(startAfter as TestEnum), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.enumValue(endAt as TestEnum), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.enumValue(endBefore as TestEnum), + ], endBeforeDocumentSnapshot: null, ); } @@ -1418,8 +1521,10 @@ class _$EnumsQuery extends QueryReference EnumsDocumentSnapshot? endBeforeDocument, EnumsDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$EnumsFieldMap['nullableEnumValue']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['nullableEnumValue']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1449,25 +1554,37 @@ class _$EnumsQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.nullableEnumValue(startAt as TestEnum?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.nullableEnumValue(startAfter as TestEnum?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.nullableEnumValue(endAt as TestEnum?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.nullableEnumValue(endBefore as TestEnum?), + ], endBeforeDocumentSnapshot: null, ); } @@ -1491,8 +1608,10 @@ class _$EnumsQuery extends QueryReference EnumsDocumentSnapshot? endBeforeDocument, EnumsDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$EnumsFieldMap['enumList']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['enumList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1522,25 +1641,37 @@ class _$EnumsQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.enumList(startAt as List), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.enumList(startAfter as List), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.enumList(endAt as List), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.enumList(endBefore as List), + ], endBeforeDocumentSnapshot: null, ); } @@ -1564,8 +1695,10 @@ class _$EnumsQuery extends QueryReference EnumsDocumentSnapshot? endBeforeDocument, EnumsDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$EnumsFieldMap['nullableEnumList']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['nullableEnumList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1595,25 +1728,37 @@ class _$EnumsQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.nullableEnumList(startAt as List?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.nullableEnumList(startAfter as List?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.nullableEnumList(endAt as List?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.nullableEnumList(endBefore as List?), + ], endBeforeDocumentSnapshot: null, ); } @@ -1644,9 +1789,7 @@ class EnumsDocumentSnapshot extends FirestoreDocumentSnapshot { @override EnumsDocumentReference get reference { - return EnumsDocumentReference( - snapshot.reference, - ); + return EnumsDocumentReference(snapshot.reference); } @override @@ -1655,33 +1798,20 @@ class EnumsDocumentSnapshot extends FirestoreDocumentSnapshot { class EnumsQuerySnapshot extends FirestoreQuerySnapshot { - EnumsQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory EnumsQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { + EnumsQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory EnumsQuerySnapshot._fromQuerySnapshot(QuerySnapshot snapshot) { final docs = snapshot.docs.map(EnumsQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - EnumsDocumentSnapshot._, - ); + return _decodeDocumentChange(change, EnumsDocumentSnapshot._); }).toList(); - return EnumsQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return EnumsQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, EnumsDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -1723,19 +1853,22 @@ class EnumsQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot // ************************************************************************** Enums _$EnumsFromJson(Map json) => Enums( - id: json['id'] as String, - enumValue: $enumDecodeNullable(_$TestEnumEnumMap, json['enumValue']) ?? - TestEnum.one, - nullableEnumValue: - $enumDecodeNullable(_$TestEnumEnumMap, json['nullableEnumValue']), - enumList: (json['enumList'] as List?) - ?.map((e) => $enumDecode(_$TestEnumEnumMap, e)) - .toList() ?? - const [], - nullableEnumList: (json['nullableEnumList'] as List?) + id: json['id'] as String, + enumValue: + $enumDecodeNullable(_$TestEnumEnumMap, json['enumValue']) ?? TestEnum.one, + nullableEnumValue: $enumDecodeNullable( + _$TestEnumEnumMap, + json['nullableEnumValue'], + ), + enumList: + (json['enumList'] as List?) ?.map((e) => $enumDecode(_$TestEnumEnumMap, e)) - .toList(), - ); + .toList() ?? + const [], + nullableEnumList: (json['nullableEnumList'] as List?) + ?.map((e) => $enumDecode(_$TestEnumEnumMap, e)) + .toList(), +); const _$EnumsFieldMap = { 'id': 'id', @@ -1763,13 +1896,14 @@ abstract class _$EnumsPerFieldToJson { } Map _$EnumsToJson(Enums instance) => { - 'id': instance.id, - 'enumValue': _$TestEnumEnumMap[instance.enumValue]!, - 'nullableEnumValue': _$TestEnumEnumMap[instance.nullableEnumValue], - 'enumList': instance.enumList.map((e) => _$TestEnumEnumMap[e]!).toList(), - 'nullableEnumList': - instance.nullableEnumList?.map((e) => _$TestEnumEnumMap[e]!).toList(), - }; + 'id': instance.id, + 'enumValue': _$TestEnumEnumMap[instance.enumValue]!, + 'nullableEnumValue': _$TestEnumEnumMap[instance.nullableEnumValue], + 'enumList': instance.enumList.map((e) => _$TestEnumEnumMap[e]!).toList(), + 'nullableEnumList': instance.nullableEnumList + ?.map((e) => _$TestEnumEnumMap[e]!) + .toList(), +}; const _$TestEnumEnumMap = { TestEnum.one: 'one', diff --git a/packages/cloud_firestore_odm/example/lib/integration/freezed.dart b/packages/cloud_firestore_odm/example/lib/integration/freezed.dart index 4453f8b..483385a 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.dart @@ -13,7 +13,7 @@ part 'freezed.g.dart'; @Collection('freezed-test') @freezed -class Person with _$Person { +abstract class Person with _$Person { @JsonSerializable(fieldRename: FieldRename.snake) factory Person({ required String firstName, @@ -28,7 +28,7 @@ final personRef = PersonCollectionReference(); @Collection('freezed-test') @freezed -class PublicRedirected with _$PublicRedirected { +abstract class PublicRedirected with _$PublicRedirected { factory PublicRedirected({required String value}) = PublicRedirected2; factory PublicRedirected.fromJson(Map json) => diff --git a/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart b/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart index 5c1d22c..268bc1b 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,357 +9,545 @@ part of 'freezed.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -Person _$PersonFromJson(Map json) { - return _Person.fromJson(json); -} - /// @nodoc mixin _$Person { - String get firstName => throw _privateConstructorUsedError; - @JsonKey(name: 'LAST_NAME') - String get lastName => throw _privateConstructorUsedError; - @JsonKey(includeFromJson: false, includeToJson: false) - int? get ignored => throw _privateConstructorUsedError; + + String get firstName;@JsonKey(name: 'LAST_NAME') String get lastName;@JsonKey(includeFromJson: false, includeToJson: false) int? get ignored; +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PersonCopyWith get copyWith => _$PersonCopyWithImpl(this as Person, _$identity); /// Serializes this Person to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PersonCopyWith get copyWith => throw _privateConstructorUsedError; + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Person&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.ignored, ignored) || other.ignored == ignored)); } -/// @nodoc -abstract class $PersonCopyWith<$Res> { - factory $PersonCopyWith(Person value, $Res Function(Person) then) = - _$PersonCopyWithImpl<$Res, Person>; - @useResult - $Res call( - {String firstName, - @JsonKey(name: 'LAST_NAME') String lastName, - @JsonKey(includeFromJson: false, includeToJson: false) int? ignored}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,firstName,lastName,ignored); + +@override +String toString() { + return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; +} + + } /// @nodoc -class _$PersonCopyWithImpl<$Res, $Val extends Person> +abstract mixin class $PersonCopyWith<$Res> { + factory $PersonCopyWith(Person value, $Res Function(Person) _then) = _$PersonCopyWithImpl; +@useResult +$Res call({ + String firstName,@JsonKey(name: 'LAST_NAME') String lastName,@JsonKey(includeFromJson: false, includeToJson: false) int? ignored +}); + + + + +} +/// @nodoc +class _$PersonCopyWithImpl<$Res> implements $PersonCopyWith<$Res> { - _$PersonCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? firstName = null, - Object? lastName = null, - Object? ignored = freezed, - }) { - return _then(_value.copyWith( - firstName: null == firstName - ? _value.firstName - : firstName // ignore: cast_nullable_to_non_nullable - as String, - lastName: null == lastName - ? _value.lastName - : lastName // ignore: cast_nullable_to_non_nullable - as String, - ignored: freezed == ignored - ? _value.ignored - : ignored // ignore: cast_nullable_to_non_nullable - as int?, - ) as $Val); - } + _$PersonCopyWithImpl(this._self, this._then); + + final Person _self; + final $Res Function(Person) _then; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? firstName = null,Object? lastName = null,Object? ignored = freezed,}) { + return _then(_self.copyWith( +firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String,ignored: freezed == ignored ? _self.ignored : ignored // ignore: cast_nullable_to_non_nullable +as int?, + )); } -/// @nodoc -abstract class _$$PersonImplCopyWith<$Res> implements $PersonCopyWith<$Res> { - factory _$$PersonImplCopyWith( - _$PersonImpl value, $Res Function(_$PersonImpl) then) = - __$$PersonImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {String firstName, - @JsonKey(name: 'LAST_NAME') String lastName, - @JsonKey(includeFromJson: false, includeToJson: false) int? ignored}); } -/// @nodoc -class __$$PersonImplCopyWithImpl<$Res> - extends _$PersonCopyWithImpl<$Res, _$PersonImpl> - implements _$$PersonImplCopyWith<$Res> { - __$$PersonImplCopyWithImpl( - _$PersonImpl _value, $Res Function(_$PersonImpl) _then) - : super(_value, _then); - - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? firstName = null, - Object? lastName = null, - Object? ignored = freezed, - }) { - return _then(_$PersonImpl( - firstName: null == firstName - ? _value.firstName - : firstName // ignore: cast_nullable_to_non_nullable - as String, - lastName: null == lastName - ? _value.lastName - : lastName // ignore: cast_nullable_to_non_nullable - as String, - ignored: freezed == ignored - ? _value.ignored - : ignored // ignore: cast_nullable_to_non_nullable - as int?, - )); - } + +/// Adds pattern-matching-related methods to [Person]. +extension PersonPatterns on Person { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _Person value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _Person value) $default,){ +final _that = this; +switch (_that) { +case _Person(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Person value)? $default,){ +final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored) $default,) {final _that = this; +switch (_that) { +case _Person(): +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored)? $default,) {final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable(fieldRename: FieldRename.snake) -class _$PersonImpl implements _Person { - _$PersonImpl( - {required this.firstName, - @JsonKey(name: 'LAST_NAME') required this.lastName, - @JsonKey(includeFromJson: false, includeToJson: false) this.ignored}); - - factory _$PersonImpl.fromJson(Map json) => - _$$PersonImplFromJson(json); - - @override - final String firstName; - @override - @JsonKey(name: 'LAST_NAME') - final String lastName; - @override - @JsonKey(includeFromJson: false, includeToJson: false) - final int? ignored; - - @override - String toString() { - return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PersonImpl && - (identical(other.firstName, firstName) || - other.firstName == firstName) && - (identical(other.lastName, lastName) || - other.lastName == lastName) && - (identical(other.ignored, ignored) || other.ignored == ignored)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, firstName, lastName, ignored); - - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PersonImplCopyWith<_$PersonImpl> get copyWith => - __$$PersonImplCopyWithImpl<_$PersonImpl>(this, _$identity); - - @override - Map toJson() { - return _$$PersonImplToJson( - this, - ); - } +class _Person implements Person { + _Person({required this.firstName, @JsonKey(name: 'LAST_NAME') required this.lastName, @JsonKey(includeFromJson: false, includeToJson: false) this.ignored}); + factory _Person.fromJson(Map json) => _$PersonFromJson(json); + +@override final String firstName; +@override@JsonKey(name: 'LAST_NAME') final String lastName; +@override@JsonKey(includeFromJson: false, includeToJson: false) final int? ignored; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PersonCopyWith<_Person> get copyWith => __$PersonCopyWithImpl<_Person>(this, _$identity); + +@override +Map toJson() { + return _$PersonToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Person&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.ignored, ignored) || other.ignored == ignored)); } -abstract class _Person implements Person { - factory _Person( - {required final String firstName, - @JsonKey(name: 'LAST_NAME') required final String lastName, - @JsonKey(includeFromJson: false, includeToJson: false) - final int? ignored}) = _$PersonImpl; +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,firstName,lastName,ignored); + +@override +String toString() { + return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; +} + + +} + +/// @nodoc +abstract mixin class _$PersonCopyWith<$Res> implements $PersonCopyWith<$Res> { + factory _$PersonCopyWith(_Person value, $Res Function(_Person) _then) = __$PersonCopyWithImpl; +@override @useResult +$Res call({ + String firstName,@JsonKey(name: 'LAST_NAME') String lastName,@JsonKey(includeFromJson: false, includeToJson: false) int? ignored +}); - factory _Person.fromJson(Map json) = _$PersonImpl.fromJson; - @override - String get firstName; - @override - @JsonKey(name: 'LAST_NAME') - String get lastName; - @override - @JsonKey(includeFromJson: false, includeToJson: false) - int? get ignored; - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PersonImplCopyWith<_$PersonImpl> get copyWith => - throw _privateConstructorUsedError; + +} +/// @nodoc +class __$PersonCopyWithImpl<$Res> + implements _$PersonCopyWith<$Res> { + __$PersonCopyWithImpl(this._self, this._then); + + final _Person _self; + final $Res Function(_Person) _then; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? firstName = null,Object? lastName = null,Object? ignored = freezed,}) { + return _then(_Person( +firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String,ignored: freezed == ignored ? _self.ignored : ignored // ignore: cast_nullable_to_non_nullable +as int?, + )); } -PublicRedirected _$PublicRedirectedFromJson(Map json) { - return PublicRedirected2.fromJson(json); + +} + +PublicRedirected _$PublicRedirectedFromJson( + Map json +) { + return PublicRedirected2.fromJson( + json + ); } /// @nodoc mixin _$PublicRedirected { - String get value => throw _privateConstructorUsedError; + + String get value; +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PublicRedirectedCopyWith get copyWith => _$PublicRedirectedCopyWithImpl(this as PublicRedirected, _$identity); /// Serializes this PublicRedirected to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PublicRedirectedCopyWith get copyWith => - throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PublicRedirected&&(identical(other.value, value) || other.value == value)); } -/// @nodoc -abstract class $PublicRedirectedCopyWith<$Res> { - factory $PublicRedirectedCopyWith( - PublicRedirected value, $Res Function(PublicRedirected) then) = - _$PublicRedirectedCopyWithImpl<$Res, PublicRedirected>; - @useResult - $Res call({String value}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,value); + +@override +String toString() { + return 'PublicRedirected(value: $value)'; } -/// @nodoc -class _$PublicRedirectedCopyWithImpl<$Res, $Val extends PublicRedirected> - implements $PublicRedirectedCopyWith<$Res> { - _$PublicRedirectedCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? value = null, - }) { - return _then(_value.copyWith( - value: null == value - ? _value.value - : value // ignore: cast_nullable_to_non_nullable - as String, - ) as $Val); - } + } /// @nodoc -abstract class _$$PublicRedirected2ImplCopyWith<$Res> +abstract mixin class $PublicRedirectedCopyWith<$Res> { + factory $PublicRedirectedCopyWith(PublicRedirected value, $Res Function(PublicRedirected) _then) = _$PublicRedirectedCopyWithImpl; +@useResult +$Res call({ + String value +}); + + + + +} +/// @nodoc +class _$PublicRedirectedCopyWithImpl<$Res> implements $PublicRedirectedCopyWith<$Res> { - factory _$$PublicRedirected2ImplCopyWith(_$PublicRedirected2Impl value, - $Res Function(_$PublicRedirected2Impl) then) = - __$$PublicRedirected2ImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({String value}); + _$PublicRedirectedCopyWithImpl(this._self, this._then); + + final PublicRedirected _self; + final $Res Function(PublicRedirected) _then; + +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? value = null,}) { + return _then(_self.copyWith( +value: null == value ? _self.value : value // ignore: cast_nullable_to_non_nullable +as String, + )); +} + +} + + +/// Adds pattern-matching-related methods to [PublicRedirected]. +extension PublicRedirectedPatterns on PublicRedirected { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( PublicRedirected2 value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( PublicRedirected2 value) $default,){ +final _that = this; +switch (_that) { +case PublicRedirected2(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( PublicRedirected2 value)? $default,){ +final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String value)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that.value);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String value) $default,) {final _that = this; +switch (_that) { +case PublicRedirected2(): +return $default(_that.value);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String value)? $default,) {final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that.value);case _: + return null; + +} } -/// @nodoc -class __$$PublicRedirected2ImplCopyWithImpl<$Res> - extends _$PublicRedirectedCopyWithImpl<$Res, _$PublicRedirected2Impl> - implements _$$PublicRedirected2ImplCopyWith<$Res> { - __$$PublicRedirected2ImplCopyWithImpl(_$PublicRedirected2Impl _value, - $Res Function(_$PublicRedirected2Impl) _then) - : super(_value, _then); - - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? value = null, - }) { - return _then(_$PublicRedirected2Impl( - value: null == value - ? _value.value - : value // ignore: cast_nullable_to_non_nullable - as String, - )); - } } /// @nodoc @JsonSerializable() -class _$PublicRedirected2Impl implements PublicRedirected2 { - _$PublicRedirected2Impl({required this.value}); - - factory _$PublicRedirected2Impl.fromJson(Map json) => - _$$PublicRedirected2ImplFromJson(json); - - @override - final String value; - - @override - String toString() { - return 'PublicRedirected(value: $value)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PublicRedirected2Impl && - (identical(other.value, value) || other.value == value)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, value); - - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PublicRedirected2ImplCopyWith<_$PublicRedirected2Impl> get copyWith => - __$$PublicRedirected2ImplCopyWithImpl<_$PublicRedirected2Impl>( - this, _$identity); - - @override - Map toJson() { - return _$$PublicRedirected2ImplToJson( - this, - ); - } + +class PublicRedirected2 implements PublicRedirected { + PublicRedirected2({required this.value}); + factory PublicRedirected2.fromJson(Map json) => _$PublicRedirected2FromJson(json); + +@override final String value; + +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PublicRedirected2CopyWith get copyWith => _$PublicRedirected2CopyWithImpl(this, _$identity); + +@override +Map toJson() { + return _$PublicRedirected2ToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PublicRedirected2&&(identical(other.value, value) || other.value == value)); } -abstract class PublicRedirected2 implements PublicRedirected { - factory PublicRedirected2({required final String value}) = - _$PublicRedirected2Impl; +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,value); + +@override +String toString() { + return 'PublicRedirected(value: $value)'; +} + + +} + +/// @nodoc +abstract mixin class $PublicRedirected2CopyWith<$Res> implements $PublicRedirectedCopyWith<$Res> { + factory $PublicRedirected2CopyWith(PublicRedirected2 value, $Res Function(PublicRedirected2) _then) = _$PublicRedirected2CopyWithImpl; +@override @useResult +$Res call({ + String value +}); - factory PublicRedirected2.fromJson(Map json) = - _$PublicRedirected2Impl.fromJson; - @override - String get value; - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PublicRedirected2ImplCopyWith<_$PublicRedirected2Impl> get copyWith => - throw _privateConstructorUsedError; + +} +/// @nodoc +class _$PublicRedirected2CopyWithImpl<$Res> + implements $PublicRedirected2CopyWith<$Res> { + _$PublicRedirected2CopyWithImpl(this._self, this._then); + + final PublicRedirected2 _self; + final $Res Function(PublicRedirected2) _then; + +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? value = null,}) { + return _then(PublicRedirected2( +value: null == value ? _self.value : value // ignore: cast_nullable_to_non_nullable +as String, + )); } + + +} + +// dart format on diff --git a/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart b/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart index 9f9482d..16371f8 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart @@ -26,9 +26,8 @@ abstract class PersonCollectionReference implements PersonQuery, FirestoreCollectionReference { - factory PersonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$PersonCollectionReference; + factory PersonCollectionReference([FirebaseFirestore? firestore]) = + _$PersonCollectionReference; static Person fromFirestore( DocumentSnapshot> snapshot, @@ -37,10 +36,7 @@ abstract class PersonCollectionReference return Person.fromJson(snapshot.data()!); } - static Map toFirestore( - Person value, - SetOptions? options, - ) { + static Map toFirestore(Person value, SetOptions? options) { return value.toJson(); } @@ -61,16 +57,17 @@ class _$PersonCollectionReference extends _$PersonQuery firestore ??= FirebaseFirestore.instance; return _$PersonCollectionReference._( - firestore.collection('freezed-test').withConverter( + firestore + .collection('freezed-test') + .withConverter( fromFirestore: PersonCollectionReference.fromFirestore, toFirestore: PersonCollectionReference.toFirestore, ), ); } - _$PersonCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$PersonCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -84,9 +81,7 @@ class _$PersonCollectionReference extends _$PersonQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return PersonDocumentReference( - reference.doc(id), - ); + return PersonDocumentReference(reference.doc(id)); } @override @@ -242,9 +237,10 @@ class _$PersonDocumentReference final json = { ...model.toJson(), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; final castedReference = reference.withConverter>( @@ -264,12 +260,17 @@ class _$PersonDocumentReference final json = { ...model.toJson(), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -282,12 +283,17 @@ class _$PersonDocumentReference final json = { ...model.toJson(), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -306,15 +312,20 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$$PersonImplFieldMap['firstName']!: - _$$PersonImplPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$$PersonImplFieldMap['lastName']!: - _$$PersonImplPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; return reference.update(json); @@ -337,15 +348,20 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$$PersonImplFieldMap['firstName']!: - _$$PersonImplPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$$PersonImplFieldMap['lastName']!: - _$$PersonImplPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; transaction.update(reference, json); @@ -368,15 +384,20 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$$PersonImplFieldMap['firstName']!: - _$$PersonImplPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$$PersonImplFieldMap['lastName']!: - _$$PersonImplPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; batch.update(reference, json); @@ -547,9 +568,9 @@ class _$PersonQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -610,7 +631,8 @@ class _$PersonQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -642,7 +664,8 @@ class _$PersonQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -665,31 +688,29 @@ class _$PersonQuery extends QueryReference return _$PersonQuery( _collection, $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PersonImplFieldMap['firstName']!, + _$PersonFieldMap['firstName']!, isEqualTo: isEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.firstName(isEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isEqualTo as String) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.firstName(isNotEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isNotEqualTo as String) : null, isLessThan: isLessThan != null - ? _$$PersonImplPerFieldToJson.firstName(isLessThan as String) + ? _$PersonPerFieldToJson.firstName(isLessThan as String) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .firstName(isLessThanOrEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isLessThanOrEqualTo as String) : null, isGreaterThan: isGreaterThan != null - ? _$$PersonImplPerFieldToJson.firstName(isGreaterThan as String) + ? _$PersonPerFieldToJson.firstName(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .firstName(isGreaterThanOrEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isGreaterThanOrEqualTo as String) : null, - whereIn: whereIn?.map((e) => _$$PersonImplPerFieldToJson.firstName(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PersonImplPerFieldToJson.firstName(e)), - isNull: isNull ?? + whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), + whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -712,31 +733,29 @@ class _$PersonQuery extends QueryReference return _$PersonQuery( _collection, $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PersonImplFieldMap['lastName']!, + _$PersonFieldMap['lastName']!, isEqualTo: isEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.lastName(isEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isEqualTo as String) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.lastName(isNotEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isNotEqualTo as String) : null, isLessThan: isLessThan != null - ? _$$PersonImplPerFieldToJson.lastName(isLessThan as String) + ? _$PersonPerFieldToJson.lastName(isLessThan as String) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .lastName(isLessThanOrEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isLessThanOrEqualTo as String) : null, isGreaterThan: isGreaterThan != null - ? _$$PersonImplPerFieldToJson.lastName(isGreaterThan as String) + ? _$PersonPerFieldToJson.lastName(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .lastName(isGreaterThanOrEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isGreaterThanOrEqualTo as String) : null, - whereIn: whereIn?.map((e) => _$$PersonImplPerFieldToJson.lastName(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PersonImplPerFieldToJson.lastName(e)), - isNull: isNull ?? + whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), + whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -757,8 +776,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -830,8 +851,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -903,8 +926,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$$PersonImplFieldMap['firstName']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$PersonFieldMap['firstName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -934,25 +959,37 @@ class _$PersonQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PersonPerFieldToJson.firstName(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PersonPerFieldToJson.firstName(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PersonPerFieldToJson.firstName(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PersonPerFieldToJson.firstName(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -976,8 +1013,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$$PersonImplFieldMap['lastName']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$PersonFieldMap['lastName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1007,25 +1046,37 @@ class _$PersonQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PersonPerFieldToJson.lastName(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PersonPerFieldToJson.lastName(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PersonPerFieldToJson.lastName(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PersonPerFieldToJson.lastName(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -1056,9 +1107,7 @@ class PersonDocumentSnapshot extends FirestoreDocumentSnapshot { @override PersonDocumentReference get reference { - return PersonDocumentReference( - snapshot.reference, - ); + return PersonDocumentReference(snapshot.reference); } @override @@ -1067,11 +1116,7 @@ class PersonDocumentSnapshot extends FirestoreDocumentSnapshot { class PersonQuerySnapshot extends FirestoreQuerySnapshot { - PersonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + PersonQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory PersonQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -1079,21 +1124,14 @@ class PersonQuerySnapshot final docs = snapshot.docs.map(PersonQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - PersonDocumentSnapshot._, - ); + return _decodeDocumentChange(change, PersonDocumentSnapshot._); }).toList(); - return PersonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return PersonQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, PersonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -1136,11 +1174,12 @@ class PersonQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot abstract class PublicRedirectedCollectionReference implements PublicRedirectedQuery, - FirestoreCollectionReference { - factory PublicRedirectedCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$PublicRedirectedCollectionReference; + FirestoreCollectionReference< + PublicRedirected, + PublicRedirectedQuerySnapshot + > { + factory PublicRedirectedCollectionReference([FirebaseFirestore? firestore]) = + _$PublicRedirectedCollectionReference; static PublicRedirected fromFirestore( DocumentSnapshot> snapshot, @@ -1169,12 +1208,15 @@ abstract class PublicRedirectedCollectionReference class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery implements PublicRedirectedCollectionReference { - factory _$PublicRedirectedCollectionReference( - [FirebaseFirestore? firestore]) { + factory _$PublicRedirectedCollectionReference([ + FirebaseFirestore? firestore, + ]) { firestore ??= FirebaseFirestore.instance; return _$PublicRedirectedCollectionReference._( - firestore.collection('freezed-test').withConverter( + firestore + .collection('freezed-test') + .withConverter( fromFirestore: PublicRedirectedCollectionReference.fromFirestore, toFirestore: PublicRedirectedCollectionReference.toFirestore, ), @@ -1197,9 +1239,7 @@ class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return PublicRedirectedDocumentReference( - reference.doc(id), - ); + return PublicRedirectedDocumentReference(reference.doc(id)); } @override @@ -1221,11 +1261,14 @@ class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery } abstract class PublicRedirectedDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + PublicRedirected, + PublicRedirectedDocumentSnapshot + > { factory PublicRedirectedDocumentReference( - DocumentReference reference) = - _$PublicRedirectedDocumentReference; + DocumentReference reference, + ) = _$PublicRedirectedDocumentReference; DocumentReference get reference; @@ -1289,10 +1332,7 @@ abstract class PublicRedirectedDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - String value, - FieldValue valueFieldValue, - }); + Future update({String value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -1313,8 +1353,12 @@ abstract class PublicRedirectedDocumentReference }); } -class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< - PublicRedirected, PublicRedirectedDocumentSnapshot> +class _$PublicRedirectedDocumentReference + extends + FirestoreDocumentReference< + PublicRedirected, + PublicRedirectedDocumentSnapshot + > implements PublicRedirectedDocumentReference { _$PublicRedirectedDocumentReference(this.reference); @@ -1338,7 +1382,8 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(PublicRedirectedDocumentSnapshot._); } @@ -1350,7 +1395,7 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< final json = { ...model.toJson(), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; final castedReference = reference.withConverter>( @@ -1369,10 +1414,14 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< final json = { ...model.toJson(), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -1384,10 +1433,14 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< final json = { ...model.toJson(), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -1400,10 +1453,11 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$$PublicRedirected2ImplFieldMap['value']!: - _$$PublicRedirected2ImplPerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; return reference.update(json); @@ -1420,10 +1474,11 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$$PublicRedirected2ImplFieldMap['value']!: - _$$PublicRedirected2ImplPerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; transaction.update(reference, json); @@ -1440,10 +1495,11 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$$PublicRedirected2ImplFieldMap['value']!: - _$$PublicRedirected2ImplPerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; batch.update(reference, json); @@ -1591,17 +1647,17 @@ class _$PublicRedirectedQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(PublicRedirectedQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + PublicRedirectedQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -1658,7 +1714,8 @@ class _$PublicRedirectedQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1690,7 +1747,8 @@ class _$PublicRedirectedQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1713,34 +1771,37 @@ class _$PublicRedirectedQuery return _$PublicRedirectedQuery( _collection, $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PublicRedirected2ImplFieldMap['value']!, + _$PublicRedirected2FieldMap['value']!, isEqualTo: isEqualTo != _sentinel - ? _$$PublicRedirected2ImplPerFieldToJson.value(isEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value(isEqualTo as String) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isNotEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value(isNotEqualTo as String) : null, isLessThan: isLessThan != null - ? _$$PublicRedirected2ImplPerFieldToJson.value(isLessThan as String) + ? _$PublicRedirected2PerFieldToJson.value(isLessThan as String) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isLessThanOrEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value( + isLessThanOrEqualTo as String, + ) : null, isGreaterThan: isGreaterThan != null - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isGreaterThan as String) + ? _$PublicRedirected2PerFieldToJson.value(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isGreaterThanOrEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value( + isGreaterThanOrEqualTo as String, + ) : null, - whereIn: whereIn - ?.map((e) => _$$PublicRedirected2ImplPerFieldToJson.value(e)), - whereNotIn: whereNotIn - ?.map((e) => _$$PublicRedirected2ImplPerFieldToJson.value(e)), - isNull: isNull ?? + whereIn: whereIn?.map( + (e) => _$PublicRedirected2PerFieldToJson.value(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$PublicRedirected2PerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1761,8 +1822,10 @@ class _$PublicRedirectedQuery PublicRedirectedDocumentSnapshot? endBeforeDocument, PublicRedirectedDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1834,8 +1897,10 @@ class _$PublicRedirectedQuery PublicRedirectedDocumentSnapshot? endBeforeDocument, PublicRedirectedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1908,8 +1973,9 @@ class _$PublicRedirectedQuery PublicRedirectedDocumentSnapshot? startAfterDocument, }) { final query = $referenceWithoutCursor.orderBy( - _$$PublicRedirected2ImplFieldMap['value']!, - descending: descending); + _$PublicRedirected2FieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1939,25 +2005,37 @@ class _$PublicRedirectedQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PublicRedirected2PerFieldToJson.value(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PublicRedirected2PerFieldToJson.value(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PublicRedirected2PerFieldToJson.value(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PublicRedirected2PerFieldToJson.value(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -1989,48 +2067,40 @@ class PublicRedirectedDocumentSnapshot @override PublicRedirectedDocumentReference get reference { - return PublicRedirectedDocumentReference( - snapshot.reference, - ); + return PublicRedirectedDocumentReference(snapshot.reference); } @override final PublicRedirected? data; } -class PublicRedirectedQuerySnapshot extends FirestoreQuerySnapshot< - PublicRedirected, PublicRedirectedQueryDocumentSnapshot> { - PublicRedirectedQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class PublicRedirectedQuerySnapshot + extends + FirestoreQuerySnapshot< + PublicRedirected, + PublicRedirectedQueryDocumentSnapshot + > { + PublicRedirectedQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory PublicRedirectedQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, ) { - final docs = - snapshot.docs.map(PublicRedirectedQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(PublicRedirectedQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - PublicRedirectedDocumentSnapshot._, - ); + return _decodeDocumentChange(change, PublicRedirectedDocumentSnapshot._); }).toList(); - return PublicRedirectedQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return PublicRedirectedQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, PublicRedirectedDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, + decodeDoc, ) { return FirestoreDocumentChange( type: docChange.type, @@ -2047,14 +2117,14 @@ class PublicRedirectedQuerySnapshot extends FirestoreQuerySnapshot< @override final List> - docChanges; + docChanges; } class PublicRedirectedQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements PublicRedirectedDocumentSnapshot { PublicRedirectedQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; @@ -2072,48 +2142,39 @@ class PublicRedirectedQueryDocumentSnapshot // JsonSerializableGenerator // ************************************************************************** -_$PersonImpl _$$PersonImplFromJson(Map json) => _$PersonImpl( - firstName: json['first_name'] as String, - lastName: json['LAST_NAME'] as String, - ); +_Person _$PersonFromJson(Map json) => _Person( + firstName: json['first_name'] as String, + lastName: json['LAST_NAME'] as String, +); -const _$$PersonImplFieldMap = { +const _$PersonFieldMap = { 'firstName': 'first_name', 'lastName': 'LAST_NAME', }; // ignore: unused_element -abstract class _$$PersonImplPerFieldToJson { +abstract class _$PersonPerFieldToJson { // ignore: unused_element static Object? firstName(String instance) => instance; // ignore: unused_element static Object? lastName(String instance) => instance; } -Map _$$PersonImplToJson(_$PersonImpl instance) => - { - 'first_name': instance.firstName, - 'LAST_NAME': instance.lastName, - }; +Map _$PersonToJson(_Person instance) => { + 'first_name': instance.firstName, + 'LAST_NAME': instance.lastName, +}; -_$PublicRedirected2Impl _$$PublicRedirected2ImplFromJson( - Map json) => - _$PublicRedirected2Impl( - value: json['value'] as String, - ); +PublicRedirected2 _$PublicRedirected2FromJson(Map json) => + PublicRedirected2(value: json['value'] as String); -const _$$PublicRedirected2ImplFieldMap = { - 'value': 'value', -}; +const _$PublicRedirected2FieldMap = {'value': 'value'}; // ignore: unused_element -abstract class _$$PublicRedirected2ImplPerFieldToJson { +abstract class _$PublicRedirected2PerFieldToJson { // ignore: unused_element static Object? value(String instance) => instance; } -Map _$$PublicRedirected2ImplToJson( - _$PublicRedirected2Impl instance) => - { - 'value': instance.value, - }; +Map _$PublicRedirected2ToJson(PublicRedirected2 instance) => + {'value': instance.value}; diff --git a/packages/cloud_firestore_odm/example/lib/integration/named_query.g.dart b/packages/cloud_firestore_odm/example/lib/integration/named_query.g.dart index 0b91d2f..1a9d8c0 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/named_query.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/named_query.g.dart @@ -19,23 +19,6 @@ class _Sentinel { const _sentinel = _Sentinel(); -/// Adds [namedBundleTest4Get] to [FirebaseFirestore]. -extension NamedBundleTest4Extrension on FirebaseFirestore { - /// Performs [FirebaseFirestore.namedQueryGet] and decode the result into - /// a [Conflict] snashot. - Future namedBundleTest4Get({ - GetOptions options = const GetOptions(), - }) async { - final snapshot = await namedQueryWithConverterGet( - r'named-bundle-test-4', - fromFirestore: ConflictCollectionReference.fromFirestore, - toFirestore: ConflictCollectionReference.toFirestore, - options: options, - ); - return ConflictQuerySnapshot._fromQuerySnapshot(snapshot); - } -} - /// A collection reference object can be used for adding documents, /// getting document references, and querying for documents /// (using the methods inherited from Query). @@ -43,9 +26,8 @@ abstract class ConflictCollectionReference implements ConflictQuery, FirestoreCollectionReference { - factory ConflictCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$ConflictCollectionReference; + factory ConflictCollectionReference([FirebaseFirestore? firestore]) = + _$ConflictCollectionReference; static Conflict fromFirestore( DocumentSnapshot> snapshot, @@ -54,10 +36,7 @@ abstract class ConflictCollectionReference return _$ConflictFromJson(snapshot.data()!); } - static Map toFirestore( - Conflict value, - SetOptions? options, - ) { + static Map toFirestore(Conflict value, SetOptions? options) { return _$ConflictToJson(value); } @@ -87,9 +66,8 @@ class _$ConflictCollectionReference extends _$ConflictQuery ); } - _$ConflictCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$ConflictCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -103,9 +81,7 @@ class _$ConflictCollectionReference extends _$ConflictQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return ConflictDocumentReference( - reference.doc(id), - ); + return ConflictDocumentReference(reference.doc(id)); } @override @@ -191,10 +167,7 @@ abstract class ConflictDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - num number, - FieldValue numberFieldValue, - }); + Future update({num number, FieldValue numberFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -208,11 +181,7 @@ abstract class ConflictDocumentReference /// Updates fields in the current document using the batch API. /// /// The update will fail if applied to a document that does not exist. - void batchUpdate( - WriteBatch batch, { - num number, - FieldValue numberFieldValue, - }); + void batchUpdate(WriteBatch batch, {num number, FieldValue numberFieldValue}); } class _$ConflictDocumentReference @@ -273,7 +242,11 @@ class _$ConflictDocumentReference _$ConflictFieldMap['number']!: numberFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -288,7 +261,11 @@ class _$ConflictDocumentReference _$ConflictFieldMap['number']!: numberFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -301,8 +278,10 @@ class _$ConflictDocumentReference ); final json = { if (number != _sentinel) - _$ConflictFieldMap['number']!: - _$ConflictPerFieldToJson.number(number as num), + _$ConflictFieldMap['number']!: _$ConflictPerFieldToJson.number( + number as num, + ), + if (numberFieldValue != null) _$ConflictFieldMap['number']!: numberFieldValue, }; @@ -321,8 +300,10 @@ class _$ConflictDocumentReference ); final json = { if (number != _sentinel) - _$ConflictFieldMap['number']!: - _$ConflictPerFieldToJson.number(number as num), + _$ConflictFieldMap['number']!: _$ConflictPerFieldToJson.number( + number as num, + ), + if (numberFieldValue != null) _$ConflictFieldMap['number']!: numberFieldValue, }; @@ -341,8 +322,10 @@ class _$ConflictDocumentReference ); final json = { if (number != _sentinel) - _$ConflictFieldMap['number']!: - _$ConflictPerFieldToJson.number(number as num), + _$ConflictFieldMap['number']!: _$ConflictPerFieldToJson.number( + number as num, + ), + if (numberFieldValue != null) _$ConflictFieldMap['number']!: numberFieldValue, }; @@ -491,9 +474,9 @@ class _$ConflictQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -556,7 +539,8 @@ class _$ConflictQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -588,7 +572,8 @@ class _$ConflictQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -632,7 +617,8 @@ class _$ConflictQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$ConflictPerFieldToJson.number(e)), whereNotIn: whereNotIn?.map((e) => _$ConflictPerFieldToJson.number(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -653,8 +639,10 @@ class _$ConflictQuery extends QueryReference ConflictDocumentSnapshot? endBeforeDocument, ConflictDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -726,8 +714,10 @@ class _$ConflictQuery extends QueryReference ConflictDocumentSnapshot? endBeforeDocument, ConflictDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -799,8 +789,10 @@ class _$ConflictQuery extends QueryReference ConflictDocumentSnapshot? endBeforeDocument, ConflictDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$ConflictFieldMap['number']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$ConflictFieldMap['number']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -830,25 +822,37 @@ class _$ConflictQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$ConflictPerFieldToJson.number(startAt as num), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$ConflictPerFieldToJson.number(startAfter as num), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$ConflictPerFieldToJson.number(endAt as num), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$ConflictPerFieldToJson.number(endBefore as num), + ], endBeforeDocumentSnapshot: null, ); } @@ -879,9 +883,7 @@ class ConflictDocumentSnapshot extends FirestoreDocumentSnapshot { @override ConflictDocumentReference get reference { - return ConflictDocumentReference( - snapshot.reference, - ); + return ConflictDocumentReference(snapshot.reference); } @override @@ -890,11 +892,7 @@ class ConflictDocumentSnapshot extends FirestoreDocumentSnapshot { class ConflictQuerySnapshot extends FirestoreQuerySnapshot { - ConflictQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + ConflictQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory ConflictQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -902,21 +900,14 @@ class ConflictQuerySnapshot final docs = snapshot.docs.map(ConflictQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - ConflictDocumentSnapshot._, - ); + return _decodeDocumentChange(change, ConflictDocumentSnapshot._); }).toList(); - return ConflictQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return ConflictQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, ConflictDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -958,13 +949,10 @@ class ConflictQueryDocumentSnapshot // JsonSerializableGenerator // ************************************************************************** -Conflict _$ConflictFromJson(Map json) => Conflict( - json['number'] as num, - ); +Conflict _$ConflictFromJson(Map json) => + Conflict(json['number'] as num); -const _$ConflictFieldMap = { - 'number': 'number', -}; +const _$ConflictFieldMap = {'number': 'number'}; // ignore: unused_element abstract class _$ConflictPerFieldToJson { @@ -973,5 +961,5 @@ abstract class _$ConflictPerFieldToJson { } Map _$ConflictToJson(Conflict instance) => { - 'number': instance.number, - }; + 'number': instance.number, +}; diff --git a/packages/cloud_firestore_odm/example/lib/integration/query.g.dart b/packages/cloud_firestore_odm/example/lib/integration/query.g.dart index be83670..6fee6c7 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/query.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/query.g.dart @@ -25,11 +25,12 @@ const _sentinel = _Sentinel(); abstract class DurationQueryCollectionReference implements DurationQueryQuery, - FirestoreCollectionReference { - factory DurationQueryCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$DurationQueryCollectionReference; + FirestoreCollectionReference< + DurationQuery, + DurationQueryQuerySnapshot + > { + factory DurationQueryCollectionReference([FirebaseFirestore? firestore]) = + _$DurationQueryCollectionReference; static DurationQuery fromFirestore( DocumentSnapshot> snapshot, @@ -62,7 +63,9 @@ class _$DurationQueryCollectionReference extends _$DurationQueryQuery firestore ??= FirebaseFirestore.instance; return _$DurationQueryCollectionReference._( - firestore.collection('firestore-example-app/42/duration').withConverter( + firestore + .collection('firestore-example-app/42/duration') + .withConverter( fromFirestore: DurationQueryCollectionReference.fromFirestore, toFirestore: DurationQueryCollectionReference.toFirestore, ), @@ -85,9 +88,7 @@ class _$DurationQueryCollectionReference extends _$DurationQueryQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return DurationQueryDocumentReference( - reference.doc(id), - ); + return DurationQueryDocumentReference(reference.doc(id)); } @override @@ -109,11 +110,14 @@ class _$DurationQueryCollectionReference extends _$DurationQueryQuery } abstract class DurationQueryDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + DurationQuery, + DurationQueryDocumentSnapshot + > { factory DurationQueryDocumentReference( - DocumentReference reference) = - _$DurationQueryDocumentReference; + DocumentReference reference, + ) = _$DurationQueryDocumentReference; DocumentReference get reference; @@ -177,10 +181,7 @@ abstract class DurationQueryDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - Duration duration, - FieldValue durationFieldValue, - }); + Future update({Duration duration, FieldValue durationFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -201,9 +202,10 @@ abstract class DurationQueryDocumentReference }); } -class _$DurationQueryDocumentReference extends FirestoreDocumentReference< - DurationQuery, - DurationQueryDocumentSnapshot> implements DurationQueryDocumentReference { +class _$DurationQueryDocumentReference + extends + FirestoreDocumentReference + implements DurationQueryDocumentReference { _$DurationQueryDocumentReference(this.reference); @override @@ -226,7 +228,8 @@ class _$DurationQueryDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(DurationQueryDocumentSnapshot._); } @@ -260,7 +263,11 @@ class _$DurationQueryDocumentReference extends FirestoreDocumentReference< _$DurationQueryFieldMap['duration']!: durationFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -275,7 +282,11 @@ class _$DurationQueryDocumentReference extends FirestoreDocumentReference< _$DurationQueryFieldMap['duration']!: durationFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -288,8 +299,9 @@ class _$DurationQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (duration != _sentinel) - _$DurationQueryFieldMap['duration']!: - _$DurationQueryPerFieldToJson.duration(duration as Duration), + _$DurationQueryFieldMap['duration']!: _$DurationQueryPerFieldToJson + .duration(duration as Duration), + if (durationFieldValue != null) _$DurationQueryFieldMap['duration']!: durationFieldValue, }; @@ -308,8 +320,9 @@ class _$DurationQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (duration != _sentinel) - _$DurationQueryFieldMap['duration']!: - _$DurationQueryPerFieldToJson.duration(duration as Duration), + _$DurationQueryFieldMap['duration']!: _$DurationQueryPerFieldToJson + .duration(duration as Duration), + if (durationFieldValue != null) _$DurationQueryFieldMap['duration']!: durationFieldValue, }; @@ -328,8 +341,9 @@ class _$DurationQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (duration != _sentinel) - _$DurationQueryFieldMap['duration']!: - _$DurationQueryPerFieldToJson.duration(duration as Duration), + _$DurationQueryFieldMap['duration']!: _$DurationQueryPerFieldToJson + .duration(duration as Duration), + if (durationFieldValue != null) _$DurationQueryFieldMap['duration']!: durationFieldValue, }; @@ -479,17 +493,17 @@ class _$DurationQueryQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(DurationQueryQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + DurationQueryQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -546,7 +560,8 @@ class _$DurationQueryQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -578,7 +593,8 @@ class _$DurationQueryQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -612,20 +628,24 @@ class _$DurationQueryQuery ? _$DurationQueryPerFieldToJson.duration(isLessThan as Duration) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$DurationQueryPerFieldToJson - .duration(isLessThanOrEqualTo as Duration) + ? _$DurationQueryPerFieldToJson.duration( + isLessThanOrEqualTo as Duration, + ) : null, isGreaterThan: isGreaterThan != null ? _$DurationQueryPerFieldToJson.duration(isGreaterThan as Duration) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$DurationQueryPerFieldToJson - .duration(isGreaterThanOrEqualTo as Duration) + ? _$DurationQueryPerFieldToJson.duration( + isGreaterThanOrEqualTo as Duration, + ) : null, whereIn: whereIn?.map((e) => _$DurationQueryPerFieldToJson.duration(e)), - whereNotIn: - whereNotIn?.map((e) => _$DurationQueryPerFieldToJson.duration(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$DurationQueryPerFieldToJson.duration(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -646,8 +666,10 @@ class _$DurationQueryQuery DurationQueryDocumentSnapshot? endBeforeDocument, DurationQueryDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -719,8 +741,10 @@ class _$DurationQueryQuery DurationQueryDocumentSnapshot? endBeforeDocument, DurationQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -792,8 +816,10 @@ class _$DurationQueryQuery DurationQueryDocumentSnapshot? endBeforeDocument, DurationQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$DurationQueryFieldMap['duration']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$DurationQueryFieldMap['duration']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -823,25 +849,37 @@ class _$DurationQueryQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$DurationQueryPerFieldToJson.duration(startAt as Duration), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$DurationQueryPerFieldToJson.duration(startAfter as Duration), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$DurationQueryPerFieldToJson.duration(endAt as Duration), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$DurationQueryPerFieldToJson.duration(endBefore as Duration), + ], endBeforeDocumentSnapshot: null, ); } @@ -873,45 +911,37 @@ class DurationQueryDocumentSnapshot @override DurationQueryDocumentReference get reference { - return DurationQueryDocumentReference( - snapshot.reference, - ); + return DurationQueryDocumentReference(snapshot.reference); } @override final DurationQuery? data; } -class DurationQueryQuerySnapshot extends FirestoreQuerySnapshot { - DurationQueryQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class DurationQueryQuerySnapshot + extends + FirestoreQuerySnapshot< + DurationQuery, + DurationQueryQueryDocumentSnapshot + > { + DurationQueryQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory DurationQueryQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, ) { - final docs = - snapshot.docs.map(DurationQueryQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(DurationQueryQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - DurationQueryDocumentSnapshot._, - ); + return _decodeDocumentChange(change, DurationQueryDocumentSnapshot._); }).toList(); - return DurationQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return DurationQueryQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, DurationQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -955,11 +985,12 @@ class DurationQueryQueryDocumentSnapshot abstract class DateTimeQueryCollectionReference implements DateTimeQueryQuery, - FirestoreCollectionReference { - factory DateTimeQueryCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$DateTimeQueryCollectionReference; + FirestoreCollectionReference< + DateTimeQuery, + DateTimeQueryQuerySnapshot + > { + factory DateTimeQueryCollectionReference([FirebaseFirestore? firestore]) = + _$DateTimeQueryCollectionReference; static DateTimeQuery fromFirestore( DocumentSnapshot> snapshot, @@ -992,7 +1023,9 @@ class _$DateTimeQueryCollectionReference extends _$DateTimeQueryQuery firestore ??= FirebaseFirestore.instance; return _$DateTimeQueryCollectionReference._( - firestore.collection('firestore-example-app/42/date-time').withConverter( + firestore + .collection('firestore-example-app/42/date-time') + .withConverter( fromFirestore: DateTimeQueryCollectionReference.fromFirestore, toFirestore: DateTimeQueryCollectionReference.toFirestore, ), @@ -1015,9 +1048,7 @@ class _$DateTimeQueryCollectionReference extends _$DateTimeQueryQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return DateTimeQueryDocumentReference( - reference.doc(id), - ); + return DateTimeQueryDocumentReference(reference.doc(id)); } @override @@ -1039,11 +1070,14 @@ class _$DateTimeQueryCollectionReference extends _$DateTimeQueryQuery } abstract class DateTimeQueryDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + DateTimeQuery, + DateTimeQueryDocumentSnapshot + > { factory DateTimeQueryDocumentReference( - DocumentReference reference) = - _$DateTimeQueryDocumentReference; + DocumentReference reference, + ) = _$DateTimeQueryDocumentReference; DocumentReference get reference; @@ -1107,10 +1141,7 @@ abstract class DateTimeQueryDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - DateTime time, - FieldValue timeFieldValue, - }); + Future update({DateTime time, FieldValue timeFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -1131,9 +1162,10 @@ abstract class DateTimeQueryDocumentReference }); } -class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< - DateTimeQuery, - DateTimeQueryDocumentSnapshot> implements DateTimeQueryDocumentReference { +class _$DateTimeQueryDocumentReference + extends + FirestoreDocumentReference + implements DateTimeQueryDocumentReference { _$DateTimeQueryDocumentReference(this.reference); @override @@ -1156,7 +1188,8 @@ class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(DateTimeQueryDocumentSnapshot._); } @@ -1190,7 +1223,11 @@ class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< _$DateTimeQueryFieldMap['time']!: timeFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -1205,7 +1242,11 @@ class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< _$DateTimeQueryFieldMap['time']!: timeFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -1218,8 +1259,10 @@ class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (time != _sentinel) - _$DateTimeQueryFieldMap['time']!: - _$DateTimeQueryPerFieldToJson.time(time as DateTime), + _$DateTimeQueryFieldMap['time']!: _$DateTimeQueryPerFieldToJson.time( + time as DateTime, + ), + if (timeFieldValue != null) _$DateTimeQueryFieldMap['time']!: timeFieldValue, }; @@ -1238,8 +1281,10 @@ class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (time != _sentinel) - _$DateTimeQueryFieldMap['time']!: - _$DateTimeQueryPerFieldToJson.time(time as DateTime), + _$DateTimeQueryFieldMap['time']!: _$DateTimeQueryPerFieldToJson.time( + time as DateTime, + ), + if (timeFieldValue != null) _$DateTimeQueryFieldMap['time']!: timeFieldValue, }; @@ -1258,8 +1303,10 @@ class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (time != _sentinel) - _$DateTimeQueryFieldMap['time']!: - _$DateTimeQueryPerFieldToJson.time(time as DateTime), + _$DateTimeQueryFieldMap['time']!: _$DateTimeQueryPerFieldToJson.time( + time as DateTime, + ), + if (timeFieldValue != null) _$DateTimeQueryFieldMap['time']!: timeFieldValue, }; @@ -1409,17 +1456,17 @@ class _$DateTimeQueryQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(DateTimeQueryQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + DateTimeQueryQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -1476,7 +1523,8 @@ class _$DateTimeQueryQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1508,7 +1556,8 @@ class _$DateTimeQueryQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1542,20 +1591,24 @@ class _$DateTimeQueryQuery ? _$DateTimeQueryPerFieldToJson.time(isLessThan as DateTime) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$DateTimeQueryPerFieldToJson - .time(isLessThanOrEqualTo as DateTime) + ? _$DateTimeQueryPerFieldToJson.time( + isLessThanOrEqualTo as DateTime, + ) : null, isGreaterThan: isGreaterThan != null ? _$DateTimeQueryPerFieldToJson.time(isGreaterThan as DateTime) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$DateTimeQueryPerFieldToJson - .time(isGreaterThanOrEqualTo as DateTime) + ? _$DateTimeQueryPerFieldToJson.time( + isGreaterThanOrEqualTo as DateTime, + ) : null, whereIn: whereIn?.map((e) => _$DateTimeQueryPerFieldToJson.time(e)), - whereNotIn: - whereNotIn?.map((e) => _$DateTimeQueryPerFieldToJson.time(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$DateTimeQueryPerFieldToJson.time(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1576,8 +1629,10 @@ class _$DateTimeQueryQuery DateTimeQueryDocumentSnapshot? endBeforeDocument, DateTimeQueryDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1649,8 +1704,10 @@ class _$DateTimeQueryQuery DateTimeQueryDocumentSnapshot? endBeforeDocument, DateTimeQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1722,8 +1779,10 @@ class _$DateTimeQueryQuery DateTimeQueryDocumentSnapshot? endBeforeDocument, DateTimeQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$DateTimeQueryFieldMap['time']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$DateTimeQueryFieldMap['time']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1753,25 +1812,37 @@ class _$DateTimeQueryQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$DateTimeQueryPerFieldToJson.time(startAt as DateTime), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$DateTimeQueryPerFieldToJson.time(startAfter as DateTime), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$DateTimeQueryPerFieldToJson.time(endAt as DateTime), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$DateTimeQueryPerFieldToJson.time(endBefore as DateTime), + ], endBeforeDocumentSnapshot: null, ); } @@ -1803,45 +1874,37 @@ class DateTimeQueryDocumentSnapshot @override DateTimeQueryDocumentReference get reference { - return DateTimeQueryDocumentReference( - snapshot.reference, - ); + return DateTimeQueryDocumentReference(snapshot.reference); } @override final DateTimeQuery? data; } -class DateTimeQueryQuerySnapshot extends FirestoreQuerySnapshot { - DateTimeQueryQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class DateTimeQueryQuerySnapshot + extends + FirestoreQuerySnapshot< + DateTimeQuery, + DateTimeQueryQueryDocumentSnapshot + > { + DateTimeQueryQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory DateTimeQueryQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, ) { - final docs = - snapshot.docs.map(DateTimeQueryQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(DateTimeQueryQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - DateTimeQueryDocumentSnapshot._, - ); + return _decodeDocumentChange(change, DateTimeQueryDocumentSnapshot._); }).toList(); - return DateTimeQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return DateTimeQueryQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, DateTimeQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -1885,11 +1948,12 @@ class DateTimeQueryQueryDocumentSnapshot abstract class TimestampQueryCollectionReference implements TimestampQueryQuery, - FirestoreCollectionReference { - factory TimestampQueryCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$TimestampQueryCollectionReference; + FirestoreCollectionReference< + TimestampQuery, + TimestampQueryQuerySnapshot + > { + factory TimestampQueryCollectionReference([FirebaseFirestore? firestore]) = + _$TimestampQueryCollectionReference; static TimestampQuery fromFirestore( DocumentSnapshot> snapshot, @@ -1947,9 +2011,7 @@ class _$TimestampQueryCollectionReference extends _$TimestampQueryQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return TimestampQueryDocumentReference( - reference.doc(id), - ); + return TimestampQueryDocumentReference(reference.doc(id)); } @override @@ -1971,11 +2033,14 @@ class _$TimestampQueryCollectionReference extends _$TimestampQueryQuery } abstract class TimestampQueryDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + TimestampQuery, + TimestampQueryDocumentSnapshot + > { factory TimestampQueryDocumentReference( - DocumentReference reference) = - _$TimestampQueryDocumentReference; + DocumentReference reference, + ) = _$TimestampQueryDocumentReference; DocumentReference get reference; @@ -2039,10 +2104,7 @@ abstract class TimestampQueryDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - Timestamp time, - FieldValue timeFieldValue, - }); + Future update({Timestamp time, FieldValue timeFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -2063,9 +2125,13 @@ abstract class TimestampQueryDocumentReference }); } -class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< - TimestampQuery, - TimestampQueryDocumentSnapshot> implements TimestampQueryDocumentReference { +class _$TimestampQueryDocumentReference + extends + FirestoreDocumentReference< + TimestampQuery, + TimestampQueryDocumentSnapshot + > + implements TimestampQueryDocumentReference { _$TimestampQueryDocumentReference(this.reference); @override @@ -2088,7 +2154,8 @@ class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(TimestampQueryDocumentSnapshot._); } @@ -2122,7 +2189,11 @@ class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< _$TimestampQueryFieldMap['time']!: timeFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -2137,7 +2208,11 @@ class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< _$TimestampQueryFieldMap['time']!: timeFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -2150,8 +2225,10 @@ class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (time != _sentinel) - _$TimestampQueryFieldMap['time']!: - _$TimestampQueryPerFieldToJson.time(time as Timestamp), + _$TimestampQueryFieldMap['time']!: _$TimestampQueryPerFieldToJson.time( + time as Timestamp, + ), + if (timeFieldValue != null) _$TimestampQueryFieldMap['time']!: timeFieldValue, }; @@ -2170,8 +2247,10 @@ class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (time != _sentinel) - _$TimestampQueryFieldMap['time']!: - _$TimestampQueryPerFieldToJson.time(time as Timestamp), + _$TimestampQueryFieldMap['time']!: _$TimestampQueryPerFieldToJson.time( + time as Timestamp, + ), + if (timeFieldValue != null) _$TimestampQueryFieldMap['time']!: timeFieldValue, }; @@ -2190,8 +2269,10 @@ class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (time != _sentinel) - _$TimestampQueryFieldMap['time']!: - _$TimestampQueryPerFieldToJson.time(time as Timestamp), + _$TimestampQueryFieldMap['time']!: _$TimestampQueryPerFieldToJson.time( + time as Timestamp, + ), + if (timeFieldValue != null) _$TimestampQueryFieldMap['time']!: timeFieldValue, }; @@ -2341,17 +2422,17 @@ class _$TimestampQueryQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(TimestampQueryQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + TimestampQueryQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -2408,7 +2489,8 @@ class _$TimestampQueryQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2440,7 +2522,8 @@ class _$TimestampQueryQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2474,20 +2557,24 @@ class _$TimestampQueryQuery ? _$TimestampQueryPerFieldToJson.time(isLessThan as Timestamp) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$TimestampQueryPerFieldToJson - .time(isLessThanOrEqualTo as Timestamp) + ? _$TimestampQueryPerFieldToJson.time( + isLessThanOrEqualTo as Timestamp, + ) : null, isGreaterThan: isGreaterThan != null ? _$TimestampQueryPerFieldToJson.time(isGreaterThan as Timestamp) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$TimestampQueryPerFieldToJson - .time(isGreaterThanOrEqualTo as Timestamp) + ? _$TimestampQueryPerFieldToJson.time( + isGreaterThanOrEqualTo as Timestamp, + ) : null, whereIn: whereIn?.map((e) => _$TimestampQueryPerFieldToJson.time(e)), - whereNotIn: - whereNotIn?.map((e) => _$TimestampQueryPerFieldToJson.time(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$TimestampQueryPerFieldToJson.time(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2508,8 +2595,10 @@ class _$TimestampQueryQuery TimestampQueryDocumentSnapshot? endBeforeDocument, TimestampQueryDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2581,8 +2670,10 @@ class _$TimestampQueryQuery TimestampQueryDocumentSnapshot? endBeforeDocument, TimestampQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2654,8 +2745,10 @@ class _$TimestampQueryQuery TimestampQueryDocumentSnapshot? endBeforeDocument, TimestampQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$TimestampQueryFieldMap['time']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$TimestampQueryFieldMap['time']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2685,25 +2778,37 @@ class _$TimestampQueryQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$TimestampQueryPerFieldToJson.time(startAt as Timestamp), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$TimestampQueryPerFieldToJson.time(startAfter as Timestamp), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$TimestampQueryPerFieldToJson.time(endAt as Timestamp), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$TimestampQueryPerFieldToJson.time(endBefore as Timestamp), + ], endBeforeDocumentSnapshot: null, ); } @@ -2735,45 +2840,37 @@ class TimestampQueryDocumentSnapshot @override TimestampQueryDocumentReference get reference { - return TimestampQueryDocumentReference( - snapshot.reference, - ); + return TimestampQueryDocumentReference(snapshot.reference); } @override final TimestampQuery? data; } -class TimestampQueryQuerySnapshot extends FirestoreQuerySnapshot { - TimestampQueryQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class TimestampQueryQuerySnapshot + extends + FirestoreQuerySnapshot< + TimestampQuery, + TimestampQueryQueryDocumentSnapshot + > { + TimestampQueryQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory TimestampQueryQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, ) { - final docs = - snapshot.docs.map(TimestampQueryQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(TimestampQueryQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - TimestampQueryDocumentSnapshot._, - ); + return _decodeDocumentChange(change, TimestampQueryDocumentSnapshot._); }).toList(); - return TimestampQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return TimestampQueryQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, TimestampQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -2792,7 +2889,7 @@ class TimestampQueryQuerySnapshot extends FirestoreQuerySnapshot> - docChanges; + docChanges; } class TimestampQueryQueryDocumentSnapshot @@ -2818,11 +2915,12 @@ class TimestampQueryQueryDocumentSnapshot abstract class GeoPointQueryCollectionReference implements GeoPointQueryQuery, - FirestoreCollectionReference { - factory GeoPointQueryCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$GeoPointQueryCollectionReference; + FirestoreCollectionReference< + GeoPointQuery, + GeoPointQueryQuerySnapshot + > { + factory GeoPointQueryCollectionReference([FirebaseFirestore? firestore]) = + _$GeoPointQueryCollectionReference; static GeoPointQuery fromFirestore( DocumentSnapshot> snapshot, @@ -2880,9 +2978,7 @@ class _$GeoPointQueryCollectionReference extends _$GeoPointQueryQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return GeoPointQueryDocumentReference( - reference.doc(id), - ); + return GeoPointQueryDocumentReference(reference.doc(id)); } @override @@ -2904,11 +3000,14 @@ class _$GeoPointQueryCollectionReference extends _$GeoPointQueryQuery } abstract class GeoPointQueryDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + GeoPointQuery, + GeoPointQueryDocumentSnapshot + > { factory GeoPointQueryDocumentReference( - DocumentReference reference) = - _$GeoPointQueryDocumentReference; + DocumentReference reference, + ) = _$GeoPointQueryDocumentReference; DocumentReference get reference; @@ -2972,10 +3071,7 @@ abstract class GeoPointQueryDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - GeoPoint point, - FieldValue pointFieldValue, - }); + Future update({GeoPoint point, FieldValue pointFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -2996,9 +3092,10 @@ abstract class GeoPointQueryDocumentReference }); } -class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< - GeoPointQuery, - GeoPointQueryDocumentSnapshot> implements GeoPointQueryDocumentReference { +class _$GeoPointQueryDocumentReference + extends + FirestoreDocumentReference + implements GeoPointQueryDocumentReference { _$GeoPointQueryDocumentReference(this.reference); @override @@ -3021,7 +3118,8 @@ class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(GeoPointQueryDocumentSnapshot._); } @@ -3055,7 +3153,11 @@ class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< _$GeoPointQueryFieldMap['point']!: pointFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -3070,7 +3172,11 @@ class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< _$GeoPointQueryFieldMap['point']!: pointFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -3083,8 +3189,10 @@ class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (point != _sentinel) - _$GeoPointQueryFieldMap['point']!: - _$GeoPointQueryPerFieldToJson.point(point as GeoPoint), + _$GeoPointQueryFieldMap['point']!: _$GeoPointQueryPerFieldToJson.point( + point as GeoPoint, + ), + if (pointFieldValue != null) _$GeoPointQueryFieldMap['point']!: pointFieldValue, }; @@ -3103,8 +3211,10 @@ class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (point != _sentinel) - _$GeoPointQueryFieldMap['point']!: - _$GeoPointQueryPerFieldToJson.point(point as GeoPoint), + _$GeoPointQueryFieldMap['point']!: _$GeoPointQueryPerFieldToJson.point( + point as GeoPoint, + ), + if (pointFieldValue != null) _$GeoPointQueryFieldMap['point']!: pointFieldValue, }; @@ -3123,8 +3233,10 @@ class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (point != _sentinel) - _$GeoPointQueryFieldMap['point']!: - _$GeoPointQueryPerFieldToJson.point(point as GeoPoint), + _$GeoPointQueryFieldMap['point']!: _$GeoPointQueryPerFieldToJson.point( + point as GeoPoint, + ), + if (pointFieldValue != null) _$GeoPointQueryFieldMap['point']!: pointFieldValue, }; @@ -3274,17 +3386,17 @@ class _$GeoPointQueryQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(GeoPointQueryQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + GeoPointQueryQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -3341,7 +3453,8 @@ class _$GeoPointQueryQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3373,7 +3486,8 @@ class _$GeoPointQueryQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3407,20 +3521,24 @@ class _$GeoPointQueryQuery ? _$GeoPointQueryPerFieldToJson.point(isLessThan as GeoPoint) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$GeoPointQueryPerFieldToJson - .point(isLessThanOrEqualTo as GeoPoint) + ? _$GeoPointQueryPerFieldToJson.point( + isLessThanOrEqualTo as GeoPoint, + ) : null, isGreaterThan: isGreaterThan != null ? _$GeoPointQueryPerFieldToJson.point(isGreaterThan as GeoPoint) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$GeoPointQueryPerFieldToJson - .point(isGreaterThanOrEqualTo as GeoPoint) + ? _$GeoPointQueryPerFieldToJson.point( + isGreaterThanOrEqualTo as GeoPoint, + ) : null, whereIn: whereIn?.map((e) => _$GeoPointQueryPerFieldToJson.point(e)), - whereNotIn: - whereNotIn?.map((e) => _$GeoPointQueryPerFieldToJson.point(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$GeoPointQueryPerFieldToJson.point(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3441,8 +3559,10 @@ class _$GeoPointQueryQuery GeoPointQueryDocumentSnapshot? endBeforeDocument, GeoPointQueryDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -3514,8 +3634,10 @@ class _$GeoPointQueryQuery GeoPointQueryDocumentSnapshot? endBeforeDocument, GeoPointQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -3587,8 +3709,10 @@ class _$GeoPointQueryQuery GeoPointQueryDocumentSnapshot? endBeforeDocument, GeoPointQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$GeoPointQueryFieldMap['point']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$GeoPointQueryFieldMap['point']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -3618,25 +3742,37 @@ class _$GeoPointQueryQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$GeoPointQueryPerFieldToJson.point(startAt as GeoPoint), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$GeoPointQueryPerFieldToJson.point(startAfter as GeoPoint), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$GeoPointQueryPerFieldToJson.point(endAt as GeoPoint), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$GeoPointQueryPerFieldToJson.point(endBefore as GeoPoint), + ], endBeforeDocumentSnapshot: null, ); } @@ -3668,45 +3804,37 @@ class GeoPointQueryDocumentSnapshot @override GeoPointQueryDocumentReference get reference { - return GeoPointQueryDocumentReference( - snapshot.reference, - ); + return GeoPointQueryDocumentReference(snapshot.reference); } @override final GeoPointQuery? data; } -class GeoPointQueryQuerySnapshot extends FirestoreQuerySnapshot { - GeoPointQueryQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class GeoPointQueryQuerySnapshot + extends + FirestoreQuerySnapshot< + GeoPointQuery, + GeoPointQueryQueryDocumentSnapshot + > { + GeoPointQueryQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory GeoPointQueryQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, ) { - final docs = - snapshot.docs.map(GeoPointQueryQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(GeoPointQueryQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - GeoPointQueryDocumentSnapshot._, - ); + return _decodeDocumentChange(change, GeoPointQueryDocumentSnapshot._); }).toList(); - return GeoPointQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return GeoPointQueryQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, GeoPointQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -3750,8 +3878,10 @@ class GeoPointQueryQueryDocumentSnapshot abstract class DocumentReferenceQueryCollectionReference implements DocumentReferenceQueryQuery, - FirestoreCollectionReference { + FirestoreCollectionReference< + DocumentReferenceQuery, + DocumentReferenceQueryQuerySnapshot + > { factory DocumentReferenceQueryCollectionReference([ FirebaseFirestore? firestore, ]) = _$DocumentReferenceQueryCollectionReference; @@ -3779,18 +3909,22 @@ abstract class DocumentReferenceQueryCollectionReference /// Add a new document to this collection with the specified data, /// assigning it a document ID automatically. Future add( - DocumentReferenceQuery value); + DocumentReferenceQuery value, + ); } class _$DocumentReferenceQueryCollectionReference extends _$DocumentReferenceQueryQuery implements DocumentReferenceQueryCollectionReference { - factory _$DocumentReferenceQueryCollectionReference( - [FirebaseFirestore? firestore]) { + factory _$DocumentReferenceQueryCollectionReference([ + FirebaseFirestore? firestore, + ]) { firestore ??= FirebaseFirestore.instance; return _$DocumentReferenceQueryCollectionReference._( - firestore.collection('firestore-example-app/42/doc-ref').withConverter( + firestore + .collection('firestore-example-app/42/doc-ref') + .withConverter( fromFirestore: DocumentReferenceQueryCollectionReference.fromFirestore, toFirestore: DocumentReferenceQueryCollectionReference.toFirestore, @@ -3814,14 +3948,13 @@ class _$DocumentReferenceQueryCollectionReference id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return DocumentReferenceQueryDocumentReference( - reference.doc(id), - ); + return DocumentReferenceQueryDocumentReference(reference.doc(id)); } @override Future add( - DocumentReferenceQuery value) { + DocumentReferenceQuery value, + ) { return reference .add(value) .then((ref) => DocumentReferenceQueryDocumentReference(ref)); @@ -3839,11 +3972,14 @@ class _$DocumentReferenceQueryCollectionReference } abstract class DocumentReferenceQueryDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + DocumentReferenceQuery, + DocumentReferenceQueryDocumentSnapshot + > { factory DocumentReferenceQueryDocumentReference( - DocumentReference reference) = - _$DocumentReferenceQueryDocumentReference; + DocumentReference reference, + ) = _$DocumentReferenceQueryDocumentReference; DocumentReference get reference; @@ -3932,8 +4068,11 @@ abstract class DocumentReferenceQueryDocumentReference } class _$DocumentReferenceQueryDocumentReference - extends FirestoreDocumentReference + extends + FirestoreDocumentReference< + DocumentReferenceQuery, + DocumentReferenceQueryDocumentSnapshot + > implements DocumentReferenceQueryDocumentReference { _$DocumentReferenceQueryDocumentReference(this.reference); @@ -3959,7 +4098,8 @@ class _$DocumentReferenceQueryDocumentReference @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction .get(reference) .then(DocumentReferenceQueryDocumentSnapshot._); @@ -3995,7 +4135,11 @@ class _$DocumentReferenceQueryDocumentReference _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -4010,7 +4154,11 @@ class _$DocumentReferenceQueryDocumentReference _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -4024,8 +4172,10 @@ class _$DocumentReferenceQueryDocumentReference final json = { if (ref != _sentinel) _$DocumentReferenceQueryFieldMap['ref']!: - _$DocumentReferenceQueryPerFieldToJson - .ref(ref as DocumentReference>), + _$DocumentReferenceQueryPerFieldToJson.ref( + ref as DocumentReference>, + ), + if (refFieldValue != null) _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, }; @@ -4045,8 +4195,10 @@ class _$DocumentReferenceQueryDocumentReference final json = { if (ref != _sentinel) _$DocumentReferenceQueryFieldMap['ref']!: - _$DocumentReferenceQueryPerFieldToJson - .ref(ref as DocumentReference>), + _$DocumentReferenceQueryPerFieldToJson.ref( + ref as DocumentReference>, + ), + if (refFieldValue != null) _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, }; @@ -4066,8 +4218,10 @@ class _$DocumentReferenceQueryDocumentReference final json = { if (ref != _sentinel) _$DocumentReferenceQueryFieldMap['ref']!: - _$DocumentReferenceQueryPerFieldToJson - .ref(ref as DocumentReference>), + _$DocumentReferenceQueryPerFieldToJson.ref( + ref as DocumentReference>, + ), + if (refFieldValue != null) _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, }; @@ -4089,8 +4243,10 @@ class _$DocumentReferenceQueryDocumentReference abstract class DocumentReferenceQueryQuery implements - QueryReference { + QueryReference< + DocumentReferenceQuery, + DocumentReferenceQueryQuerySnapshot + > { @override DocumentReferenceQueryQuery limit(int limit); @@ -4211,26 +4367,31 @@ abstract class DocumentReferenceQueryQuery }); } -class _$DocumentReferenceQueryQuery extends QueryReference< - DocumentReferenceQuery, DocumentReferenceQueryQuerySnapshot> +class _$DocumentReferenceQueryQuery + extends + QueryReference< + DocumentReferenceQuery, + DocumentReferenceQueryQuerySnapshot + > implements DocumentReferenceQueryQuery { _$DocumentReferenceQueryQuery( this._collection, { required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override - Stream snapshots( - [SnapshotOptions? options]) { - return reference - .snapshots() - .map(DocumentReferenceQueryQuerySnapshot._fromQuerySnapshot); + Stream snapshots([ + SnapshotOptions? options, + ]) { + return reference.snapshots().map( + DocumentReferenceQueryQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -4287,7 +4448,8 @@ class _$DocumentReferenceQueryQuery extends QueryReference< arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -4319,7 +4481,8 @@ class _$DocumentReferenceQueryQuery extends QueryReference< isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -4344,34 +4507,44 @@ class _$DocumentReferenceQueryQuery extends QueryReference< $referenceWithoutCursor: $referenceWithoutCursor.where( _$DocumentReferenceQueryFieldMap['ref']!, isEqualTo: isEqualTo != _sentinel - ? _$DocumentReferenceQueryPerFieldToJson - .ref(isEqualTo as DocumentReference>) + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isEqualTo as DocumentReference>, + ) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$DocumentReferenceQueryPerFieldToJson - .ref(isNotEqualTo as DocumentReference>) + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isNotEqualTo as DocumentReference>, + ) : null, isLessThan: isLessThan != null - ? _$DocumentReferenceQueryPerFieldToJson - .ref(isLessThan as DocumentReference>) + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isLessThan as DocumentReference>, + ) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null ? _$DocumentReferenceQueryPerFieldToJson.ref( - isLessThanOrEqualTo as DocumentReference>) + isLessThanOrEqualTo as DocumentReference>, + ) : null, isGreaterThan: isGreaterThan != null - ? _$DocumentReferenceQueryPerFieldToJson - .ref(isGreaterThan as DocumentReference>) + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isGreaterThan as DocumentReference>, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$DocumentReferenceQueryPerFieldToJson.ref(isGreaterThanOrEqualTo - as DocumentReference>) + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isGreaterThanOrEqualTo + as DocumentReference>, + ) : null, - whereIn: - whereIn?.map((e) => _$DocumentReferenceQueryPerFieldToJson.ref(e)), - whereNotIn: whereNotIn - ?.map((e) => _$DocumentReferenceQueryPerFieldToJson.ref(e)), - isNull: isNull ?? + whereIn: whereIn?.map( + (e) => _$DocumentReferenceQueryPerFieldToJson.ref(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$DocumentReferenceQueryPerFieldToJson.ref(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -4392,8 +4565,10 @@ class _$DocumentReferenceQueryQuery extends QueryReference< DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, DocumentReferenceQueryDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4465,8 +4640,10 @@ class _$DocumentReferenceQueryQuery extends QueryReference< DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, DocumentReferenceQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4539,8 +4716,9 @@ class _$DocumentReferenceQueryQuery extends QueryReference< DocumentReferenceQueryDocumentSnapshot? startAfterDocument, }) { final query = $referenceWithoutCursor.orderBy( - _$DocumentReferenceQueryFieldMap['ref']!, - descending: descending); + _$DocumentReferenceQueryFieldMap['ref']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4570,25 +4748,45 @@ class _$DocumentReferenceQueryQuery extends QueryReference< if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$DocumentReferenceQueryPerFieldToJson.ref( + startAt as DocumentReference>, + ), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$DocumentReferenceQueryPerFieldToJson.ref( + startAfter as DocumentReference>, + ), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$DocumentReferenceQueryPerFieldToJson.ref( + endAt as DocumentReference>, + ), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$DocumentReferenceQueryPerFieldToJson.ref( + endBefore as DocumentReference>, + ), + ], endBeforeDocumentSnapshot: null, ); } @@ -4614,24 +4812,26 @@ class _$DocumentReferenceQueryQuery extends QueryReference< class DocumentReferenceQueryDocumentSnapshot extends FirestoreDocumentSnapshot { DocumentReferenceQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final DocumentSnapshot snapshot; @override DocumentReferenceQueryDocumentReference get reference { - return DocumentReferenceQueryDocumentReference( - snapshot.reference, - ); + return DocumentReferenceQueryDocumentReference(snapshot.reference); } @override final DocumentReferenceQuery? data; } -class DocumentReferenceQueryQuerySnapshot extends FirestoreQuerySnapshot< - DocumentReferenceQuery, DocumentReferenceQueryQueryDocumentSnapshot> { +class DocumentReferenceQueryQuerySnapshot + extends + FirestoreQuerySnapshot< + DocumentReferenceQuery, + DocumentReferenceQueryQueryDocumentSnapshot + > { DocumentReferenceQueryQuerySnapshot._( this.snapshot, this.docs, @@ -4652,18 +4852,14 @@ class DocumentReferenceQueryQuerySnapshot extends FirestoreQuerySnapshot< ); }).toList(); - return DocumentReferenceQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return DocumentReferenceQueryQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, DocumentReferenceQueryDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, + decodeDoc, ) { return FirestoreDocumentChange( type: docChange.type, @@ -4680,14 +4876,14 @@ class DocumentReferenceQueryQuerySnapshot extends FirestoreQuerySnapshot< @override final List> - docChanges; + docChanges; } class DocumentReferenceQueryQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements DocumentReferenceQueryDocumentSnapshot { DocumentReferenceQueryQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; @@ -4706,13 +4902,9 @@ class DocumentReferenceQueryQueryDocumentSnapshot // ************************************************************************** DurationQuery _$DurationQueryFromJson(Map json) => - DurationQuery( - Duration(microseconds: (json['duration'] as num).toInt()), - ); + DurationQuery(Duration(microseconds: (json['duration'] as num).toInt())); -const _$DurationQueryFieldMap = { - 'duration': 'duration', -}; +const _$DurationQueryFieldMap = {'duration': 'duration'}; // ignore: unused_element abstract class _$DurationQueryPerFieldToJson { @@ -4721,18 +4913,14 @@ abstract class _$DurationQueryPerFieldToJson { } Map _$DurationQueryToJson(DurationQuery instance) => - { - 'duration': instance.duration.inMicroseconds, - }; + {'duration': instance.duration.inMicroseconds}; DateTimeQuery _$DateTimeQueryFromJson(Map json) => DateTimeQuery( const FirestoreDateTimeConverter().fromJson(json['time'] as Timestamp), ); -const _$DateTimeQueryFieldMap = { - 'time': 'time', -}; +const _$DateTimeQueryFieldMap = {'time': 'time'}; // ignore: unused_element abstract class _$DateTimeQueryPerFieldToJson { @@ -4751,9 +4939,7 @@ TimestampQuery _$TimestampQueryFromJson(Map json) => const FirestoreTimestampConverter().fromJson(json['time'] as Timestamp), ); -const _$TimestampQueryFieldMap = { - 'time': 'time', -}; +const _$TimestampQueryFieldMap = {'time': 'time'}; // ignore: unused_element abstract class _$TimestampQueryPerFieldToJson { @@ -4772,9 +4958,7 @@ GeoPointQuery _$GeoPointQueryFromJson(Map json) => const FirestoreGeoPointConverter().fromJson(json['point'] as GeoPoint), ); -const _$GeoPointQueryFieldMap = { - 'point': 'point', -}; +const _$GeoPointQueryFieldMap = {'point': 'point'}; // ignore: unused_element abstract class _$GeoPointQueryPerFieldToJson { @@ -4789,15 +4973,14 @@ Map _$GeoPointQueryToJson(GeoPointQuery instance) => }; DocumentReferenceQuery _$DocumentReferenceQueryFromJson( - Map json) => - DocumentReferenceQuery( - const FirestoreDocumentReferenceConverter() - .fromJson(json['ref'] as DocumentReference>), - ); + Map json, +) => DocumentReferenceQuery( + const FirestoreDocumentReferenceConverter().fromJson( + json['ref'] as DocumentReference>, + ), +); -const _$DocumentReferenceQueryFieldMap = { - 'ref': 'ref', -}; +const _$DocumentReferenceQueryFieldMap = {'ref': 'ref'}; // ignore: unused_element abstract class _$DocumentReferenceQueryPerFieldToJson { @@ -4807,7 +4990,7 @@ abstract class _$DocumentReferenceQueryPerFieldToJson { } Map _$DocumentReferenceQueryToJson( - DocumentReferenceQuery instance) => - { - 'ref': const FirestoreDocumentReferenceConverter().toJson(instance.ref), - }; + DocumentReferenceQuery instance, +) => { + 'ref': const FirestoreDocumentReferenceConverter().toJson(instance.ref), +}; diff --git a/packages/cloud_firestore_odm/example/lib/movie.g.dart b/packages/cloud_firestore_odm/example/lib/movie.g.dart index f12e30a..a1b19f3 100644 --- a/packages/cloud_firestore_odm/example/lib/movie.g.dart +++ b/packages/cloud_firestore_odm/example/lib/movie.g.dart @@ -26,9 +26,8 @@ abstract class MovieCollectionReference implements MovieQuery, FirestoreCollectionReference { - factory MovieCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$MovieCollectionReference; + factory MovieCollectionReference([FirebaseFirestore? firestore]) = + _$MovieCollectionReference; static Movie fromFirestore( DocumentSnapshot> snapshot, @@ -37,10 +36,7 @@ abstract class MovieCollectionReference return _$MovieFromJson({'id': snapshot.id, ...?snapshot.data()}); } - static Map toFirestore( - Movie value, - SetOptions? options, - ) { + static Map toFirestore(Movie value, SetOptions? options) { return {..._$MovieToJson(value)}..remove('id'); } @@ -61,16 +57,17 @@ class _$MovieCollectionReference extends _$MovieQuery firestore ??= FirebaseFirestore.instance; return _$MovieCollectionReference._( - firestore.collection('firestore-example-app').withConverter( + firestore + .collection('firestore-example-app') + .withConverter( fromFirestore: MovieCollectionReference.fromFirestore, toFirestore: MovieCollectionReference.toFirestore, ), ); } - _$MovieCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$MovieCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -84,9 +81,7 @@ class _$MovieCollectionReference extends _$MovieQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return MovieDocumentReference( - reference.doc(id), - ); + return MovieDocumentReference(reference.doc(id)); } @override @@ -311,19 +306,26 @@ class _$MovieDocumentReference ..._$MovieToJson(model), if (posterFieldValue != null) _$MovieFieldMap['poster']!: posterFieldValue, + if (likesFieldValue != null) _$MovieFieldMap['likes']!: likesFieldValue, + if (titleFieldValue != null) _$MovieFieldMap['title']!: titleFieldValue, + if (yearFieldValue != null) _$MovieFieldMap['year']!: yearFieldValue, + if (runtimeFieldValue != null) _$MovieFieldMap['runtime']!: runtimeFieldValue, + if (ratedFieldValue != null) _$MovieFieldMap['rated']!: ratedFieldValue, + if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, + if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, }; final castedReference = reference.withConverter>( fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, + toFirestore: (value, options) => value..remove('id'), ); return castedReference.set(json, options); } @@ -345,17 +347,28 @@ class _$MovieDocumentReference ..._$MovieToJson(model), if (posterFieldValue != null) _$MovieFieldMap['poster']!: posterFieldValue, + if (likesFieldValue != null) _$MovieFieldMap['likes']!: likesFieldValue, + if (titleFieldValue != null) _$MovieFieldMap['title']!: titleFieldValue, + if (yearFieldValue != null) _$MovieFieldMap['year']!: yearFieldValue, + if (runtimeFieldValue != null) _$MovieFieldMap['runtime']!: runtimeFieldValue, + if (ratedFieldValue != null) _$MovieFieldMap['rated']!: ratedFieldValue, + if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, + if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value..remove('id'), + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -375,17 +388,28 @@ class _$MovieDocumentReference ..._$MovieToJson(model), if (posterFieldValue != null) _$MovieFieldMap['poster']!: posterFieldValue, + if (likesFieldValue != null) _$MovieFieldMap['likes']!: likesFieldValue, + if (titleFieldValue != null) _$MovieFieldMap['title']!: titleFieldValue, + if (yearFieldValue != null) _$MovieFieldMap['year']!: yearFieldValue, + if (runtimeFieldValue != null) _$MovieFieldMap['runtime']!: runtimeFieldValue, + if (ratedFieldValue != null) _$MovieFieldMap['rated']!: ratedFieldValue, + if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, + if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value..remove('id'), + ); + batch.set(castedReference, json, options); } Future update({ @@ -440,34 +464,53 @@ class _$MovieDocumentReference ); final json = { if (poster != _sentinel) - _$MovieFieldMap['poster']!: - _$MoviePerFieldToJson.poster(poster as String), + _$MovieFieldMap['poster']!: _$MoviePerFieldToJson.poster( + poster as String, + ), + if (posterFieldValue != null) _$MovieFieldMap['poster']!: posterFieldValue, + if (likes != _sentinel) _$MovieFieldMap['likes']!: _$MoviePerFieldToJson.likes(likes as int), + if (likesFieldValue != null) _$MovieFieldMap['likes']!: likesFieldValue, + if (title != _sentinel) _$MovieFieldMap['title']!: _$MoviePerFieldToJson.title(title as String), + if (titleFieldValue != null) _$MovieFieldMap['title']!: titleFieldValue, + if (year != _sentinel) _$MovieFieldMap['year']!: _$MoviePerFieldToJson.year(year as int), + if (yearFieldValue != null) _$MovieFieldMap['year']!: yearFieldValue, + if (runtime != _sentinel) - _$MovieFieldMap['runtime']!: - _$MoviePerFieldToJson.runtime(runtime as String), + _$MovieFieldMap['runtime']!: _$MoviePerFieldToJson.runtime( + runtime as String, + ), + if (runtimeFieldValue != null) _$MovieFieldMap['runtime']!: runtimeFieldValue, + if (rated != _sentinel) _$MovieFieldMap['rated']!: _$MoviePerFieldToJson.rated(rated as String), + if (ratedFieldValue != null) _$MovieFieldMap['rated']!: ratedFieldValue, + if (genre != _sentinel) - _$MovieFieldMap['genre']!: - _$MoviePerFieldToJson.genre(genre as List?), + _$MovieFieldMap['genre']!: _$MoviePerFieldToJson.genre( + genre as List?, + ), + if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, + if (tags != _sentinel) - _$MovieFieldMap['tags']!: - _$MoviePerFieldToJson.tags(tags as Set?), + _$MovieFieldMap['tags']!: _$MoviePerFieldToJson.tags( + tags as Set?, + ), + if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, }; @@ -527,34 +570,53 @@ class _$MovieDocumentReference ); final json = { if (poster != _sentinel) - _$MovieFieldMap['poster']!: - _$MoviePerFieldToJson.poster(poster as String), + _$MovieFieldMap['poster']!: _$MoviePerFieldToJson.poster( + poster as String, + ), + if (posterFieldValue != null) _$MovieFieldMap['poster']!: posterFieldValue, + if (likes != _sentinel) _$MovieFieldMap['likes']!: _$MoviePerFieldToJson.likes(likes as int), + if (likesFieldValue != null) _$MovieFieldMap['likes']!: likesFieldValue, + if (title != _sentinel) _$MovieFieldMap['title']!: _$MoviePerFieldToJson.title(title as String), + if (titleFieldValue != null) _$MovieFieldMap['title']!: titleFieldValue, + if (year != _sentinel) _$MovieFieldMap['year']!: _$MoviePerFieldToJson.year(year as int), + if (yearFieldValue != null) _$MovieFieldMap['year']!: yearFieldValue, + if (runtime != _sentinel) - _$MovieFieldMap['runtime']!: - _$MoviePerFieldToJson.runtime(runtime as String), + _$MovieFieldMap['runtime']!: _$MoviePerFieldToJson.runtime( + runtime as String, + ), + if (runtimeFieldValue != null) _$MovieFieldMap['runtime']!: runtimeFieldValue, + if (rated != _sentinel) _$MovieFieldMap['rated']!: _$MoviePerFieldToJson.rated(rated as String), + if (ratedFieldValue != null) _$MovieFieldMap['rated']!: ratedFieldValue, + if (genre != _sentinel) - _$MovieFieldMap['genre']!: - _$MoviePerFieldToJson.genre(genre as List?), + _$MovieFieldMap['genre']!: _$MoviePerFieldToJson.genre( + genre as List?, + ), + if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, + if (tags != _sentinel) - _$MovieFieldMap['tags']!: - _$MoviePerFieldToJson.tags(tags as Set?), + _$MovieFieldMap['tags']!: _$MoviePerFieldToJson.tags( + tags as Set?, + ), + if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, }; @@ -614,34 +676,53 @@ class _$MovieDocumentReference ); final json = { if (poster != _sentinel) - _$MovieFieldMap['poster']!: - _$MoviePerFieldToJson.poster(poster as String), + _$MovieFieldMap['poster']!: _$MoviePerFieldToJson.poster( + poster as String, + ), + if (posterFieldValue != null) _$MovieFieldMap['poster']!: posterFieldValue, + if (likes != _sentinel) _$MovieFieldMap['likes']!: _$MoviePerFieldToJson.likes(likes as int), + if (likesFieldValue != null) _$MovieFieldMap['likes']!: likesFieldValue, + if (title != _sentinel) _$MovieFieldMap['title']!: _$MoviePerFieldToJson.title(title as String), + if (titleFieldValue != null) _$MovieFieldMap['title']!: titleFieldValue, + if (year != _sentinel) _$MovieFieldMap['year']!: _$MoviePerFieldToJson.year(year as int), + if (yearFieldValue != null) _$MovieFieldMap['year']!: yearFieldValue, + if (runtime != _sentinel) - _$MovieFieldMap['runtime']!: - _$MoviePerFieldToJson.runtime(runtime as String), + _$MovieFieldMap['runtime']!: _$MoviePerFieldToJson.runtime( + runtime as String, + ), + if (runtimeFieldValue != null) _$MovieFieldMap['runtime']!: runtimeFieldValue, + if (rated != _sentinel) _$MovieFieldMap['rated']!: _$MoviePerFieldToJson.rated(rated as String), + if (ratedFieldValue != null) _$MovieFieldMap['rated']!: ratedFieldValue, + if (genre != _sentinel) - _$MovieFieldMap['genre']!: - _$MoviePerFieldToJson.genre(genre as List?), + _$MovieFieldMap['genre']!: _$MoviePerFieldToJson.genre( + genre as List?, + ), + if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, + if (tags != _sentinel) - _$MovieFieldMap['tags']!: - _$MoviePerFieldToJson.tags(tags as Set?), + _$MovieFieldMap['tags']!: _$MoviePerFieldToJson.tags( + tags as Set?, + ), + if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, }; @@ -956,9 +1037,9 @@ class _$MovieQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -1019,7 +1100,8 @@ class _$MovieQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1051,7 +1133,8 @@ class _$MovieQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1095,7 +1178,8 @@ class _$MovieQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.poster(e)), whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.poster(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1139,7 +1223,8 @@ class _$MovieQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.likes(e)), whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.likes(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1183,7 +1268,8 @@ class _$MovieQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.title(e)), whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.title(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1227,7 +1313,8 @@ class _$MovieQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.year(e)), whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.year(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1271,7 +1358,8 @@ class _$MovieQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.runtime(e)), whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.runtime(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1315,7 +1403,8 @@ class _$MovieQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.rated(e)), whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.rated(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1355,17 +1444,19 @@ class _$MovieQuery extends QueryReference ? _$MoviePerFieldToJson.genre(isGreaterThan as List?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$MoviePerFieldToJson - .genre(isGreaterThanOrEqualTo as List?) + ? _$MoviePerFieldToJson.genre( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null ? (_$MoviePerFieldToJson.genre([arrayContains as String]) as List?)! - .single + .single : null, arrayContainsAny: arrayContainsAny != null ? _$MoviePerFieldToJson.genre(arrayContainsAny) as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1409,12 +1500,13 @@ class _$MovieQuery extends QueryReference : null, arrayContains: arrayContains != null ? (_$MoviePerFieldToJson.tags({arrayContains as String}) as List?)! - .single + .single : null, arrayContainsAny: arrayContainsAny != null ? _$MoviePerFieldToJson.tags(arrayContainsAny) as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1435,8 +1527,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1508,8 +1602,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1581,8 +1677,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['poster']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['poster']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1612,25 +1710,37 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.poster(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.poster(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.poster(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.poster(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -1654,8 +1764,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['likes']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['likes']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1685,25 +1797,37 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.likes(startAt as int), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.likes(startAfter as int), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.likes(endAt as int), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.likes(endBefore as int), + ], endBeforeDocumentSnapshot: null, ); } @@ -1727,8 +1851,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['title']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['title']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1758,25 +1884,37 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.title(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.title(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.title(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.title(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -1800,8 +1938,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['year']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['year']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1831,25 +1971,34 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.year(startAt as int), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.year(startAfter as int), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [...queryCursor.endAt, _$MoviePerFieldToJson.year(endAt as int)], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.year(endBefore as int), + ], endBeforeDocumentSnapshot: null, ); } @@ -1873,8 +2022,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['runtime']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['runtime']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1904,25 +2055,37 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.runtime(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.runtime(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.runtime(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.runtime(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -1946,8 +2109,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['rated']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['rated']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1977,25 +2142,37 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.rated(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.rated(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.rated(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.rated(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -2019,8 +2196,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['genre']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['genre']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2050,25 +2229,37 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.genre(startAt as List?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.genre(startAfter as List?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.genre(endAt as List?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.genre(endBefore as List?), + ], endBeforeDocumentSnapshot: null, ); } @@ -2092,8 +2283,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['tags']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['tags']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2123,25 +2316,37 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.tags(startAt as Set?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.tags(startAfter as Set?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.tags(endAt as Set?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.tags(endBefore as Set?), + ], endBeforeDocumentSnapshot: null, ); } @@ -2172,9 +2377,7 @@ class MovieDocumentSnapshot extends FirestoreDocumentSnapshot { @override MovieDocumentReference get reference { - return MovieDocumentReference( - snapshot.reference, - ); + return MovieDocumentReference(snapshot.reference); } @override @@ -2183,33 +2386,20 @@ class MovieDocumentSnapshot extends FirestoreDocumentSnapshot { class MovieQuerySnapshot extends FirestoreQuerySnapshot { - MovieQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + MovieQuerySnapshot._(this.snapshot, this.docs, this.docChanges); - factory MovieQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { + factory MovieQuerySnapshot._fromQuerySnapshot(QuerySnapshot snapshot) { final docs = snapshot.docs.map(MovieQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - MovieDocumentSnapshot._, - ); + return _decodeDocumentChange(change, MovieDocumentSnapshot._); }).toList(); - return MovieQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return MovieQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, MovieDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -2253,9 +2443,8 @@ abstract class CommentCollectionReference implements CommentQuery, FirestoreCollectionReference { - factory CommentCollectionReference( - DocumentReference parent, - ) = _$CommentCollectionReference; + factory CommentCollectionReference(DocumentReference parent) = + _$CommentCollectionReference; static Comment fromFirestore( DocumentSnapshot> snapshot, @@ -2264,10 +2453,7 @@ abstract class CommentCollectionReference return _$CommentFromJson(snapshot.data()!); } - static Map toFirestore( - Comment value, - SetOptions? options, - ) { + static Map toFirestore(Comment value, SetOptions? options) { return _$CommentToJson(value); } @@ -2287,12 +2473,12 @@ abstract class CommentCollectionReference class _$CommentCollectionReference extends _$CommentQuery implements CommentCollectionReference { - factory _$CommentCollectionReference( - DocumentReference parent, - ) { + factory _$CommentCollectionReference(DocumentReference parent) { return _$CommentCollectionReference._( MovieDocumentReference(parent), - parent.collection('comments').withConverter( + parent + .collection('comments') + .withConverter( fromFirestore: CommentCollectionReference.fromFirestore, toFirestore: CommentCollectionReference.toFirestore, ), @@ -2319,9 +2505,7 @@ class _$CommentCollectionReference extends _$CommentQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return CommentDocumentReference( - reference.doc(id), - ); + return CommentDocumentReference(reference.doc(id)); } @override @@ -2488,6 +2672,7 @@ class _$CommentDocumentReference ..._$CommentToJson(model), if (authorNameFieldValue != null) _$CommentFieldMap['authorName']!: authorNameFieldValue, + if (messageFieldValue != null) _$CommentFieldMap['message']!: messageFieldValue, }; @@ -2510,11 +2695,16 @@ class _$CommentDocumentReference ..._$CommentToJson(model), if (authorNameFieldValue != null) _$CommentFieldMap['authorName']!: authorNameFieldValue, + if (messageFieldValue != null) _$CommentFieldMap['message']!: messageFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -2528,11 +2718,16 @@ class _$CommentDocumentReference ..._$CommentToJson(model), if (authorNameFieldValue != null) _$CommentFieldMap['authorName']!: authorNameFieldValue, + if (messageFieldValue != null) _$CommentFieldMap['message']!: messageFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -2551,13 +2746,18 @@ class _$CommentDocumentReference ); final json = { if (authorName != _sentinel) - _$CommentFieldMap['authorName']!: - _$CommentPerFieldToJson.authorName(authorName as String), + _$CommentFieldMap['authorName']!: _$CommentPerFieldToJson.authorName( + authorName as String, + ), + if (authorNameFieldValue != null) _$CommentFieldMap['authorName']!: authorNameFieldValue, + if (message != _sentinel) - _$CommentFieldMap['message']!: - _$CommentPerFieldToJson.message(message as String), + _$CommentFieldMap['message']!: _$CommentPerFieldToJson.message( + message as String, + ), + if (messageFieldValue != null) _$CommentFieldMap['message']!: messageFieldValue, }; @@ -2582,13 +2782,18 @@ class _$CommentDocumentReference ); final json = { if (authorName != _sentinel) - _$CommentFieldMap['authorName']!: - _$CommentPerFieldToJson.authorName(authorName as String), + _$CommentFieldMap['authorName']!: _$CommentPerFieldToJson.authorName( + authorName as String, + ), + if (authorNameFieldValue != null) _$CommentFieldMap['authorName']!: authorNameFieldValue, + if (message != _sentinel) - _$CommentFieldMap['message']!: - _$CommentPerFieldToJson.message(message as String), + _$CommentFieldMap['message']!: _$CommentPerFieldToJson.message( + message as String, + ), + if (messageFieldValue != null) _$CommentFieldMap['message']!: messageFieldValue, }; @@ -2613,13 +2818,18 @@ class _$CommentDocumentReference ); final json = { if (authorName != _sentinel) - _$CommentFieldMap['authorName']!: - _$CommentPerFieldToJson.authorName(authorName as String), + _$CommentFieldMap['authorName']!: _$CommentPerFieldToJson.authorName( + authorName as String, + ), + if (authorNameFieldValue != null) _$CommentFieldMap['authorName']!: authorNameFieldValue, + if (message != _sentinel) - _$CommentFieldMap['message']!: - _$CommentPerFieldToJson.message(message as String), + _$CommentFieldMap['message']!: _$CommentPerFieldToJson.message( + message as String, + ), + if (messageFieldValue != null) _$CommentFieldMap['message']!: messageFieldValue, }; @@ -2792,9 +3002,9 @@ class _$CommentQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -2855,7 +3065,8 @@ class _$CommentQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2887,7 +3098,8 @@ class _$CommentQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2927,13 +3139,16 @@ class _$CommentQuery extends QueryReference ? _$CommentPerFieldToJson.authorName(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$CommentPerFieldToJson - .authorName(isGreaterThanOrEqualTo as String) + ? _$CommentPerFieldToJson.authorName( + isGreaterThanOrEqualTo as String, + ) : null, whereIn: whereIn?.map((e) => _$CommentPerFieldToJson.authorName(e)), - whereNotIn: - whereNotIn?.map((e) => _$CommentPerFieldToJson.authorName(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$CommentPerFieldToJson.authorName(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2977,7 +3192,8 @@ class _$CommentQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$CommentPerFieldToJson.message(e)), whereNotIn: whereNotIn?.map((e) => _$CommentPerFieldToJson.message(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2998,8 +3214,10 @@ class _$CommentQuery extends QueryReference CommentDocumentSnapshot? endBeforeDocument, CommentDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -3071,8 +3289,10 @@ class _$CommentQuery extends QueryReference CommentDocumentSnapshot? endBeforeDocument, CommentDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -3144,8 +3364,10 @@ class _$CommentQuery extends QueryReference CommentDocumentSnapshot? endBeforeDocument, CommentDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$CommentFieldMap['authorName']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$CommentFieldMap['authorName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -3175,25 +3397,37 @@ class _$CommentQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$CommentPerFieldToJson.authorName(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$CommentPerFieldToJson.authorName(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$CommentPerFieldToJson.authorName(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$CommentPerFieldToJson.authorName(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -3217,8 +3451,10 @@ class _$CommentQuery extends QueryReference CommentDocumentSnapshot? endBeforeDocument, CommentDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$CommentFieldMap['message']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$CommentFieldMap['message']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -3248,25 +3484,37 @@ class _$CommentQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$CommentPerFieldToJson.message(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$CommentPerFieldToJson.message(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$CommentPerFieldToJson.message(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$CommentPerFieldToJson.message(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -3297,9 +3545,7 @@ class CommentDocumentSnapshot extends FirestoreDocumentSnapshot { @override CommentDocumentReference get reference { - return CommentDocumentReference( - snapshot.reference, - ); + return CommentDocumentReference(snapshot.reference); } @override @@ -3308,11 +3554,7 @@ class CommentDocumentSnapshot extends FirestoreDocumentSnapshot { class CommentQuerySnapshot extends FirestoreQuerySnapshot { - CommentQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + CommentQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory CommentQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -3320,21 +3562,14 @@ class CommentQuerySnapshot final docs = snapshot.docs.map(CommentQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - CommentDocumentSnapshot._, - ); + return _decodeDocumentChange(change, CommentDocumentSnapshot._); }).toList(); - return CommentQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return CommentQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, CommentDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -3386,17 +3621,16 @@ void _$assertMovie(Movie instance) { // ************************************************************************** Movie _$MovieFromJson(Map json) => Movie( - genre: - (json['genre'] as List?)?.map((e) => e as String).toList(), - tags: (json['tags'] as List?)?.map((e) => e as String).toSet(), - likes: (json['likes'] as num).toInt(), - poster: json['poster'] as String, - rated: json['rated'] as String, - runtime: json['runtime'] as String, - title: json['title'] as String, - year: (json['year'] as num).toInt(), - id: json['id'] as String, - ); + genre: (json['genre'] as List?)?.map((e) => e as String).toList(), + tags: (json['tags'] as List?)?.map((e) => e as String).toSet(), + likes: (json['likes'] as num).toInt(), + poster: json['poster'] as String, + rated: json['rated'] as String, + runtime: json['runtime'] as String, + title: json['title'] as String, + year: (json['year'] as num).toInt(), + id: json['id'] as String, +); const _$MovieFieldMap = { 'id': 'id', @@ -3433,21 +3667,21 @@ abstract class _$MoviePerFieldToJson { } Map _$MovieToJson(Movie instance) => { - 'id': instance.id, - 'poster': instance.poster, - 'likes': instance.likes, - 'title': instance.title, - 'year': instance.year, - 'runtime': instance.runtime, - 'rated': instance.rated, - 'genre': instance.genre, - 'tags': instance.tags?.toList(), - }; + 'id': instance.id, + 'poster': instance.poster, + 'likes': instance.likes, + 'title': instance.title, + 'year': instance.year, + 'runtime': instance.runtime, + 'rated': instance.rated, + 'genre': instance.genre, + 'tags': instance.tags?.toList(), +}; Comment _$CommentFromJson(Map json) => Comment( - authorName: json['authorName'] as String, - message: json['message'] as String, - ); + authorName: json['authorName'] as String, + message: json['message'] as String, +); const _$CommentFieldMap = { 'authorName': 'authorName', @@ -3463,6 +3697,6 @@ abstract class _$CommentPerFieldToJson { } Map _$CommentToJson(Comment instance) => { - 'authorName': instance.authorName, - 'message': instance.message, - }; + 'authorName': instance.authorName, + 'message': instance.message, +}; diff --git a/packages/cloud_firestore_odm/example/pubspec.yaml b/packages/cloud_firestore_odm/example/pubspec.yaml index f7354cb..729164d 100644 --- a/packages/cloud_firestore_odm/example/pubspec.yaml +++ b/packages/cloud_firestore_odm/example/pubspec.yaml @@ -2,31 +2,31 @@ name: cloud_firestore_odm_example publish_to: none environment: - sdk: '>=2.18.0 <4.0.0' + sdk: ">=3.8.0 <4.0.0" dependencies: - cloud_firestore: ^5.0.0 - cloud_firestore_odm: ^1.0.0-dev.85 - firebase_core: ^3.0.0 + cloud_firestore: ^6.0.0 + cloud_firestore_odm: ^1.2.0 + firebase_core: ^4.0.0 flutter: sdk: flutter - freezed_annotation: ^2.2.0 - json_annotation: ^4.8.1 + freezed_annotation: ^3.1.0 + json_annotation: ^4.9.0 meta: ^1.12.0 dev_dependencies: - build_runner: ^2.4.2 + build_runner: ^2.7.0 cloud_firestore_odm_generator: path: ../../cloud_firestore_odm_generator cloud_firestore_odm_generator_integration_test: path: ../../cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test flutter_test: sdk: flutter - freezed: ^2.3.2 + freezed: ^3.2.0 http: ^1.0.0 integration_test: sdk: flutter - json_serializable: ^6.6.1 + json_serializable: ^6.11.0 mockito: ^5.0.0 dependency_overrides: diff --git a/packages/cloud_firestore_odm/example/web/index.html b/packages/cloud_firestore_odm/example/web/index.html index ab4fd86..86c769e 100644 --- a/packages/cloud_firestore_odm/example/web/index.html +++ b/packages/cloud_firestore_odm/example/web/index.html @@ -30,72 +30,6 @@ - - + diff --git a/packages/cloud_firestore_odm/pubspec.yaml b/packages/cloud_firestore_odm/pubspec.yaml index 1873718..877eb88 100644 --- a/packages/cloud_firestore_odm/pubspec.yaml +++ b/packages/cloud_firestore_odm/pubspec.yaml @@ -2,21 +2,22 @@ name: cloud_firestore_odm description: An ODM for Firebase Cloud Firestore (cloud_firestore). homepage: https://github.com/firebaseextended/firestoreodm-flutter repository: https://github.com/firebaseextended/firestoreodm-flutter -version: 1.0.0-dev.88 +version: 1.3.0 false_secrets: - example/** environment: - sdk: '>=2.18.0 <4.0.0' + sdk: ">=3.8.0 <4.0.0" dependencies: - cloud_firestore: ^5.0.0 + cloud_firestore: ^6.0.0 flutter: sdk: flutter - json_annotation: ^4.8.1 + json_annotation: ^4.9.0 meta: ^1.12.0 dev_dependencies: flutter_test: sdk: flutter + test: ^1.25.15 diff --git a/packages/cloud_firestore_odm_generator/CHANGELOG.md b/packages/cloud_firestore_odm_generator/CHANGELOG.md index 28119ba..58f2c8c 100644 --- a/packages/cloud_firestore_odm_generator/CHANGELOG.md +++ b/packages/cloud_firestore_odm_generator/CHANGELOG.md @@ -1,3 +1,16 @@ +## 1.3.0 +- **CHORE**: upgraded packages to support analyzer ^8 and min sdk to 3.8.0 + +## 1.2.0 +- **FIX**: `set`, `batchSet` and `transactionSet` methods would keep the `@ID() id` in the object in DB. +- **CHORE**: Update cloud_firestore to ^6.0.0 + +## 1.1.0 + +- **FIX**: Resolve compatibility issues with Freezed 3.0.0 and above +- **FEAT**: Support analyzer: ^7.0.0 and source_gen: ^2.0.0 +- **CHORE**: Update dependencies to latest versions + ## 1.0.0-dev.90 - 2025-02-23 - Ignore static getters on annotated classes (thanks to @Rexios80) diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.dart index 4453f8b..e243b7f 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.dart +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.dart @@ -13,7 +13,7 @@ part 'freezed.g.dart'; @Collection('freezed-test') @freezed -class Person with _$Person { +abstract class Person with _$Person { @JsonSerializable(fieldRename: FieldRename.snake) factory Person({ required String firstName, @@ -27,10 +27,28 @@ class Person with _$Person { final personRef = PersonCollectionReference(); @Collection('freezed-test') +final publicRedirectedRef = PublicRedirectedCollectionReference(); + @freezed -class PublicRedirected with _$PublicRedirected { +abstract class PublicRedirected with _$PublicRedirected { factory PublicRedirected({required String value}) = PublicRedirected2; - factory PublicRedirected.fromJson(Map json) => - _$PublicRedirectedFromJson(json); + factory PublicRedirected.fromJson(Map json) => _$PublicRedirectedFromJson(json); } + +/// Freezed 3.x mixed mode +/// +/// Simple classes +@freezed +@JsonSerializable() +class SimpleFreezed with _$SimpleFreezed { + const SimpleFreezed({required this.a}); + factory SimpleFreezed.fromJson(Map json) => _$SimpleFreezedFromJson(json); + + @override + final int a; + Map toJson() => _$SimpleFreezedToJson(this); +} + +@Collection('freezed-test') +final simpleFreezedRef = SimpleFreezedCollectionReference(); diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.freezed.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.freezed.dart index 5c1d22c..fcfe548 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.freezed.dart +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,357 +9,731 @@ part of 'freezed.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -Person _$PersonFromJson(Map json) { - return _Person.fromJson(json); -} - /// @nodoc mixin _$Person { - String get firstName => throw _privateConstructorUsedError; - @JsonKey(name: 'LAST_NAME') - String get lastName => throw _privateConstructorUsedError; - @JsonKey(includeFromJson: false, includeToJson: false) - int? get ignored => throw _privateConstructorUsedError; + + String get firstName;@JsonKey(name: 'LAST_NAME') String get lastName;@JsonKey(includeFromJson: false, includeToJson: false) int? get ignored; +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PersonCopyWith get copyWith => _$PersonCopyWithImpl(this as Person, _$identity); /// Serializes this Person to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PersonCopyWith get copyWith => throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Person&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.ignored, ignored) || other.ignored == ignored)); } -/// @nodoc -abstract class $PersonCopyWith<$Res> { - factory $PersonCopyWith(Person value, $Res Function(Person) then) = - _$PersonCopyWithImpl<$Res, Person>; - @useResult - $Res call( - {String firstName, - @JsonKey(name: 'LAST_NAME') String lastName, - @JsonKey(includeFromJson: false, includeToJson: false) int? ignored}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,firstName,lastName,ignored); + +@override +String toString() { + return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; +} + + } /// @nodoc -class _$PersonCopyWithImpl<$Res, $Val extends Person> +abstract mixin class $PersonCopyWith<$Res> { + factory $PersonCopyWith(Person value, $Res Function(Person) _then) = _$PersonCopyWithImpl; +@useResult +$Res call({ + String firstName,@JsonKey(name: 'LAST_NAME') String lastName,@JsonKey(includeFromJson: false, includeToJson: false) int? ignored +}); + + + + +} +/// @nodoc +class _$PersonCopyWithImpl<$Res> implements $PersonCopyWith<$Res> { - _$PersonCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? firstName = null, - Object? lastName = null, - Object? ignored = freezed, - }) { - return _then(_value.copyWith( - firstName: null == firstName - ? _value.firstName - : firstName // ignore: cast_nullable_to_non_nullable - as String, - lastName: null == lastName - ? _value.lastName - : lastName // ignore: cast_nullable_to_non_nullable - as String, - ignored: freezed == ignored - ? _value.ignored - : ignored // ignore: cast_nullable_to_non_nullable - as int?, - ) as $Val); - } + _$PersonCopyWithImpl(this._self, this._then); + + final Person _self; + final $Res Function(Person) _then; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? firstName = null,Object? lastName = null,Object? ignored = freezed,}) { + return _then(_self.copyWith( +firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String,ignored: freezed == ignored ? _self.ignored : ignored // ignore: cast_nullable_to_non_nullable +as int?, + )); } -/// @nodoc -abstract class _$$PersonImplCopyWith<$Res> implements $PersonCopyWith<$Res> { - factory _$$PersonImplCopyWith( - _$PersonImpl value, $Res Function(_$PersonImpl) then) = - __$$PersonImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {String firstName, - @JsonKey(name: 'LAST_NAME') String lastName, - @JsonKey(includeFromJson: false, includeToJson: false) int? ignored}); } -/// @nodoc -class __$$PersonImplCopyWithImpl<$Res> - extends _$PersonCopyWithImpl<$Res, _$PersonImpl> - implements _$$PersonImplCopyWith<$Res> { - __$$PersonImplCopyWithImpl( - _$PersonImpl _value, $Res Function(_$PersonImpl) _then) - : super(_value, _then); - - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? firstName = null, - Object? lastName = null, - Object? ignored = freezed, - }) { - return _then(_$PersonImpl( - firstName: null == firstName - ? _value.firstName - : firstName // ignore: cast_nullable_to_non_nullable - as String, - lastName: null == lastName - ? _value.lastName - : lastName // ignore: cast_nullable_to_non_nullable - as String, - ignored: freezed == ignored - ? _value.ignored - : ignored // ignore: cast_nullable_to_non_nullable - as int?, - )); - } + +/// Adds pattern-matching-related methods to [Person]. +extension PersonPatterns on Person { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _Person value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _Person value) $default,){ +final _that = this; +switch (_that) { +case _Person(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Person value)? $default,){ +final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored) $default,) {final _that = this; +switch (_that) { +case _Person(): +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored)? $default,) {final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable(fieldRename: FieldRename.snake) -class _$PersonImpl implements _Person { - _$PersonImpl( - {required this.firstName, - @JsonKey(name: 'LAST_NAME') required this.lastName, - @JsonKey(includeFromJson: false, includeToJson: false) this.ignored}); - - factory _$PersonImpl.fromJson(Map json) => - _$$PersonImplFromJson(json); - - @override - final String firstName; - @override - @JsonKey(name: 'LAST_NAME') - final String lastName; - @override - @JsonKey(includeFromJson: false, includeToJson: false) - final int? ignored; - - @override - String toString() { - return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PersonImpl && - (identical(other.firstName, firstName) || - other.firstName == firstName) && - (identical(other.lastName, lastName) || - other.lastName == lastName) && - (identical(other.ignored, ignored) || other.ignored == ignored)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, firstName, lastName, ignored); - - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PersonImplCopyWith<_$PersonImpl> get copyWith => - __$$PersonImplCopyWithImpl<_$PersonImpl>(this, _$identity); - - @override - Map toJson() { - return _$$PersonImplToJson( - this, - ); - } +class _Person implements Person { + _Person({required this.firstName, @JsonKey(name: 'LAST_NAME') required this.lastName, @JsonKey(includeFromJson: false, includeToJson: false) this.ignored}); + factory _Person.fromJson(Map json) => _$PersonFromJson(json); + +@override final String firstName; +@override@JsonKey(name: 'LAST_NAME') final String lastName; +@override@JsonKey(includeFromJson: false, includeToJson: false) final int? ignored; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PersonCopyWith<_Person> get copyWith => __$PersonCopyWithImpl<_Person>(this, _$identity); + +@override +Map toJson() { + return _$PersonToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Person&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.ignored, ignored) || other.ignored == ignored)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,firstName,lastName,ignored); + +@override +String toString() { + return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; } -abstract class _Person implements Person { - factory _Person( - {required final String firstName, - @JsonKey(name: 'LAST_NAME') required final String lastName, - @JsonKey(includeFromJson: false, includeToJson: false) - final int? ignored}) = _$PersonImpl; - factory _Person.fromJson(Map json) = _$PersonImpl.fromJson; +} + +/// @nodoc +abstract mixin class _$PersonCopyWith<$Res> implements $PersonCopyWith<$Res> { + factory _$PersonCopyWith(_Person value, $Res Function(_Person) _then) = __$PersonCopyWithImpl; +@override @useResult +$Res call({ + String firstName,@JsonKey(name: 'LAST_NAME') String lastName,@JsonKey(includeFromJson: false, includeToJson: false) int? ignored +}); + + + + +} +/// @nodoc +class __$PersonCopyWithImpl<$Res> + implements _$PersonCopyWith<$Res> { + __$PersonCopyWithImpl(this._self, this._then); + + final _Person _self; + final $Res Function(_Person) _then; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? firstName = null,Object? lastName = null,Object? ignored = freezed,}) { + return _then(_Person( +firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String,ignored: freezed == ignored ? _self.ignored : ignored // ignore: cast_nullable_to_non_nullable +as int?, + )); +} - @override - String get firstName; - @override - @JsonKey(name: 'LAST_NAME') - String get lastName; - @override - @JsonKey(includeFromJson: false, includeToJson: false) - int? get ignored; - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PersonImplCopyWith<_$PersonImpl> get copyWith => - throw _privateConstructorUsedError; } -PublicRedirected _$PublicRedirectedFromJson(Map json) { - return PublicRedirected2.fromJson(json); +PublicRedirected _$PublicRedirectedFromJson( + Map json +) { + return PublicRedirected2.fromJson( + json + ); } /// @nodoc mixin _$PublicRedirected { - String get value => throw _privateConstructorUsedError; + + String get value; +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PublicRedirectedCopyWith get copyWith => _$PublicRedirectedCopyWithImpl(this as PublicRedirected, _$identity); /// Serializes this PublicRedirected to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PublicRedirectedCopyWith get copyWith => - throw _privateConstructorUsedError; + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PublicRedirected&&(identical(other.value, value) || other.value == value)); } -/// @nodoc -abstract class $PublicRedirectedCopyWith<$Res> { - factory $PublicRedirectedCopyWith( - PublicRedirected value, $Res Function(PublicRedirected) then) = - _$PublicRedirectedCopyWithImpl<$Res, PublicRedirected>; - @useResult - $Res call({String value}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,value); + +@override +String toString() { + return 'PublicRedirected(value: $value)'; } + +} + +/// @nodoc +abstract mixin class $PublicRedirectedCopyWith<$Res> { + factory $PublicRedirectedCopyWith(PublicRedirected value, $Res Function(PublicRedirected) _then) = _$PublicRedirectedCopyWithImpl; +@useResult +$Res call({ + String value +}); + + + + +} /// @nodoc -class _$PublicRedirectedCopyWithImpl<$Res, $Val extends PublicRedirected> +class _$PublicRedirectedCopyWithImpl<$Res> implements $PublicRedirectedCopyWith<$Res> { - _$PublicRedirectedCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? value = null, - }) { - return _then(_value.copyWith( - value: null == value - ? _value.value - : value // ignore: cast_nullable_to_non_nullable - as String, - ) as $Val); - } + _$PublicRedirectedCopyWithImpl(this._self, this._then); + + final PublicRedirected _self; + final $Res Function(PublicRedirected) _then; + +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? value = null,}) { + return _then(_self.copyWith( +value: null == value ? _self.value : value // ignore: cast_nullable_to_non_nullable +as String, + )); +} + +} + + +/// Adds pattern-matching-related methods to [PublicRedirected]. +extension PublicRedirectedPatterns on PublicRedirected { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( PublicRedirected2 value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( PublicRedirected2 value) $default,){ +final _that = this; +switch (_that) { +case PublicRedirected2(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( PublicRedirected2 value)? $default,){ +final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String value)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that.value);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String value) $default,) {final _that = this; +switch (_that) { +case PublicRedirected2(): +return $default(_that.value);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String value)? $default,) {final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that.value);case _: + return null; + +} +} + } /// @nodoc -abstract class _$$PublicRedirected2ImplCopyWith<$Res> - implements $PublicRedirectedCopyWith<$Res> { - factory _$$PublicRedirected2ImplCopyWith(_$PublicRedirected2Impl value, - $Res Function(_$PublicRedirected2Impl) then) = - __$$PublicRedirected2ImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({String value}); +@JsonSerializable() + +class PublicRedirected2 implements PublicRedirected { + PublicRedirected2({required this.value}); + factory PublicRedirected2.fromJson(Map json) => _$PublicRedirected2FromJson(json); + +@override final String value; + +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PublicRedirected2CopyWith get copyWith => _$PublicRedirected2CopyWithImpl(this, _$identity); + +@override +Map toJson() { + return _$PublicRedirected2ToJson(this, ); } +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PublicRedirected2&&(identical(other.value, value) || other.value == value)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,value); + +@override +String toString() { + return 'PublicRedirected(value: $value)'; +} + + +} + +/// @nodoc +abstract mixin class $PublicRedirected2CopyWith<$Res> implements $PublicRedirectedCopyWith<$Res> { + factory $PublicRedirected2CopyWith(PublicRedirected2 value, $Res Function(PublicRedirected2) _then) = _$PublicRedirected2CopyWithImpl; +@override @useResult +$Res call({ + String value +}); + + + + +} /// @nodoc -class __$$PublicRedirected2ImplCopyWithImpl<$Res> - extends _$PublicRedirectedCopyWithImpl<$Res, _$PublicRedirected2Impl> - implements _$$PublicRedirected2ImplCopyWith<$Res> { - __$$PublicRedirected2ImplCopyWithImpl(_$PublicRedirected2Impl _value, - $Res Function(_$PublicRedirected2Impl) _then) - : super(_value, _then); - - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? value = null, - }) { - return _then(_$PublicRedirected2Impl( - value: null == value - ? _value.value - : value // ignore: cast_nullable_to_non_nullable - as String, - )); - } +class _$PublicRedirected2CopyWithImpl<$Res> + implements $PublicRedirected2CopyWith<$Res> { + _$PublicRedirected2CopyWithImpl(this._self, this._then); + + final PublicRedirected2 _self; + final $Res Function(PublicRedirected2) _then; + +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? value = null,}) { + return _then(PublicRedirected2( +value: null == value ? _self.value : value // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + } + /// @nodoc -@JsonSerializable() -class _$PublicRedirected2Impl implements PublicRedirected2 { - _$PublicRedirected2Impl({required this.value}); - - factory _$PublicRedirected2Impl.fromJson(Map json) => - _$$PublicRedirected2ImplFromJson(json); - - @override - final String value; - - @override - String toString() { - return 'PublicRedirected(value: $value)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PublicRedirected2Impl && - (identical(other.value, value) || other.value == value)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, value); - - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PublicRedirected2ImplCopyWith<_$PublicRedirected2Impl> get copyWith => - __$$PublicRedirected2ImplCopyWithImpl<_$PublicRedirected2Impl>( - this, _$identity); - - @override - Map toJson() { - return _$$PublicRedirected2ImplToJson( - this, - ); - } +mixin _$SimpleFreezed { + + int get a; +/// Create a copy of SimpleFreezed +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SimpleFreezedCopyWith get copyWith => _$SimpleFreezedCopyWithImpl(this as SimpleFreezed, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SimpleFreezed&&(identical(other.a, a) || other.a == a)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,a); + +@override +String toString() { + return 'SimpleFreezed(a: $a)'; +} + + } -abstract class PublicRedirected2 implements PublicRedirected { - factory PublicRedirected2({required final String value}) = - _$PublicRedirected2Impl; +/// @nodoc +abstract mixin class $SimpleFreezedCopyWith<$Res> { + factory $SimpleFreezedCopyWith(SimpleFreezed value, $Res Function(SimpleFreezed) _then) = _$SimpleFreezedCopyWithImpl; +@useResult +$Res call({ + int a +}); + + + + +} +/// @nodoc +class _$SimpleFreezedCopyWithImpl<$Res> + implements $SimpleFreezedCopyWith<$Res> { + _$SimpleFreezedCopyWithImpl(this._self, this._then); + + final SimpleFreezed _self; + final $Res Function(SimpleFreezed) _then; + +/// Create a copy of SimpleFreezed +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? a = null,}) { + return _then(SimpleFreezed( +a: null == a ? _self.a : a // ignore: cast_nullable_to_non_nullable +as int, + )); +} + +} - factory PublicRedirected2.fromJson(Map json) = - _$PublicRedirected2Impl.fromJson; - @override - String get value; +/// Adds pattern-matching-related methods to [SimpleFreezed]. +extension SimpleFreezedPatterns on SimpleFreezed { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap({required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _: + return orElse(); - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PublicRedirected2ImplCopyWith<_$PublicRedirected2Impl> get copyWith => - throw _privateConstructorUsedError; } +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(){ +final _that = this; +switch (_that) { +case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(){ +final _that = this; +switch (_that) { +case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen({required TResult orElse(),}) {final _that = this; +switch (_that) { +case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when() {final _that = this; +switch (_that) { +case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull() {final _that = this; +switch (_that) { +case _: + return null; + +} +} + +} + +// dart format on diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.g.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.g.dart index 7ca05a2..a3f0e99 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.g.dart +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.g.dart @@ -24,9 +24,8 @@ abstract class PersonCollectionReference implements PersonQuery, FirestoreCollectionReference { - factory PersonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$PersonCollectionReference; + factory PersonCollectionReference([FirebaseFirestore? firestore]) = + _$PersonCollectionReference; static Person fromFirestore( DocumentSnapshot> snapshot, @@ -35,10 +34,7 @@ abstract class PersonCollectionReference return Person.fromJson(snapshot.data()!); } - static Map toFirestore( - Person value, - SetOptions? options, - ) { + static Map toFirestore(Person value, SetOptions? options) { return value.toJson(); } @@ -59,16 +55,17 @@ class _$PersonCollectionReference extends _$PersonQuery firestore ??= FirebaseFirestore.instance; return _$PersonCollectionReference._( - firestore.collection('freezed-test').withConverter( + firestore + .collection('freezed-test') + .withConverter( fromFirestore: PersonCollectionReference.fromFirestore, toFirestore: PersonCollectionReference.toFirestore, ), ); } - _$PersonCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$PersonCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -82,9 +79,7 @@ class _$PersonCollectionReference extends _$PersonQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return PersonDocumentReference( - reference.doc(id), - ); + return PersonDocumentReference(reference.doc(id)); } @override @@ -240,9 +235,10 @@ class _$PersonDocumentReference final json = { ...model.toJson(), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; final castedReference = reference.withConverter>( @@ -262,12 +258,17 @@ class _$PersonDocumentReference final json = { ...model.toJson(), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -280,12 +281,17 @@ class _$PersonDocumentReference final json = { ...model.toJson(), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -304,15 +310,20 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$$PersonImplFieldMap['firstName']!: - _$$PersonImplPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$$PersonImplFieldMap['lastName']!: - _$$PersonImplPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; return reference.update(json); @@ -335,15 +346,20 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$$PersonImplFieldMap['firstName']!: - _$$PersonImplPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$$PersonImplFieldMap['lastName']!: - _$$PersonImplPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; transaction.update(reference, json); @@ -366,15 +382,20 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$$PersonImplFieldMap['firstName']!: - _$$PersonImplPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$$PersonImplFieldMap['lastName']!: - _$$PersonImplPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; batch.update(reference, json); @@ -545,9 +566,9 @@ class _$PersonQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -608,7 +629,8 @@ class _$PersonQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -640,7 +662,8 @@ class _$PersonQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -663,31 +686,29 @@ class _$PersonQuery extends QueryReference return _$PersonQuery( _collection, $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PersonImplFieldMap['firstName']!, + _$PersonFieldMap['firstName']!, isEqualTo: isEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.firstName(isEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isEqualTo as String) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.firstName(isNotEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isNotEqualTo as String) : null, isLessThan: isLessThan != null - ? _$$PersonImplPerFieldToJson.firstName(isLessThan as String) + ? _$PersonPerFieldToJson.firstName(isLessThan as String) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .firstName(isLessThanOrEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isLessThanOrEqualTo as String) : null, isGreaterThan: isGreaterThan != null - ? _$$PersonImplPerFieldToJson.firstName(isGreaterThan as String) + ? _$PersonPerFieldToJson.firstName(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .firstName(isGreaterThanOrEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isGreaterThanOrEqualTo as String) : null, - whereIn: whereIn?.map((e) => _$$PersonImplPerFieldToJson.firstName(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PersonImplPerFieldToJson.firstName(e)), - isNull: isNull ?? + whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), + whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -710,31 +731,29 @@ class _$PersonQuery extends QueryReference return _$PersonQuery( _collection, $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PersonImplFieldMap['lastName']!, + _$PersonFieldMap['lastName']!, isEqualTo: isEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.lastName(isEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isEqualTo as String) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.lastName(isNotEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isNotEqualTo as String) : null, isLessThan: isLessThan != null - ? _$$PersonImplPerFieldToJson.lastName(isLessThan as String) + ? _$PersonPerFieldToJson.lastName(isLessThan as String) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .lastName(isLessThanOrEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isLessThanOrEqualTo as String) : null, isGreaterThan: isGreaterThan != null - ? _$$PersonImplPerFieldToJson.lastName(isGreaterThan as String) + ? _$PersonPerFieldToJson.lastName(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .lastName(isGreaterThanOrEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isGreaterThanOrEqualTo as String) : null, - whereIn: whereIn?.map((e) => _$$PersonImplPerFieldToJson.lastName(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PersonImplPerFieldToJson.lastName(e)), - isNull: isNull ?? + whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), + whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -755,8 +774,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -828,8 +849,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -901,8 +924,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$$PersonImplFieldMap['firstName']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$PersonFieldMap['firstName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -932,25 +957,37 @@ class _$PersonQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PersonPerFieldToJson.firstName(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PersonPerFieldToJson.firstName(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PersonPerFieldToJson.firstName(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PersonPerFieldToJson.firstName(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -974,8 +1011,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$$PersonImplFieldMap['lastName']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$PersonFieldMap['lastName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1005,25 +1044,37 @@ class _$PersonQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PersonPerFieldToJson.lastName(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PersonPerFieldToJson.lastName(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PersonPerFieldToJson.lastName(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PersonPerFieldToJson.lastName(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -1054,9 +1105,7 @@ class PersonDocumentSnapshot extends FirestoreDocumentSnapshot { @override PersonDocumentReference get reference { - return PersonDocumentReference( - snapshot.reference, - ); + return PersonDocumentReference(snapshot.reference); } @override @@ -1065,11 +1114,7 @@ class PersonDocumentSnapshot extends FirestoreDocumentSnapshot { class PersonQuerySnapshot extends FirestoreQuerySnapshot { - PersonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + PersonQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory PersonQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -1077,21 +1122,14 @@ class PersonQuerySnapshot final docs = snapshot.docs.map(PersonQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - PersonDocumentSnapshot._, - ); + return _decodeDocumentChange(change, PersonDocumentSnapshot._); }).toList(); - return PersonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return PersonQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, PersonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -1134,11 +1172,12 @@ class PersonQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot abstract class PublicRedirectedCollectionReference implements PublicRedirectedQuery, - FirestoreCollectionReference { - factory PublicRedirectedCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$PublicRedirectedCollectionReference; + FirestoreCollectionReference< + PublicRedirected, + PublicRedirectedQuerySnapshot + > { + factory PublicRedirectedCollectionReference([FirebaseFirestore? firestore]) = + _$PublicRedirectedCollectionReference; static PublicRedirected fromFirestore( DocumentSnapshot> snapshot, @@ -1167,12 +1206,15 @@ abstract class PublicRedirectedCollectionReference class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery implements PublicRedirectedCollectionReference { - factory _$PublicRedirectedCollectionReference( - [FirebaseFirestore? firestore]) { + factory _$PublicRedirectedCollectionReference([ + FirebaseFirestore? firestore, + ]) { firestore ??= FirebaseFirestore.instance; return _$PublicRedirectedCollectionReference._( - firestore.collection('freezed-test').withConverter( + firestore + .collection('freezed-test') + .withConverter( fromFirestore: PublicRedirectedCollectionReference.fromFirestore, toFirestore: PublicRedirectedCollectionReference.toFirestore, ), @@ -1195,9 +1237,7 @@ class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return PublicRedirectedDocumentReference( - reference.doc(id), - ); + return PublicRedirectedDocumentReference(reference.doc(id)); } @override @@ -1219,11 +1259,14 @@ class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery } abstract class PublicRedirectedDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + PublicRedirected, + PublicRedirectedDocumentSnapshot + > { factory PublicRedirectedDocumentReference( - DocumentReference reference) = - _$PublicRedirectedDocumentReference; + DocumentReference reference, + ) = _$PublicRedirectedDocumentReference; DocumentReference get reference; @@ -1287,10 +1330,7 @@ abstract class PublicRedirectedDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - String value, - FieldValue valueFieldValue, - }); + Future update({String value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -1311,8 +1351,12 @@ abstract class PublicRedirectedDocumentReference }); } -class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< - PublicRedirected, PublicRedirectedDocumentSnapshot> +class _$PublicRedirectedDocumentReference + extends + FirestoreDocumentReference< + PublicRedirected, + PublicRedirectedDocumentSnapshot + > implements PublicRedirectedDocumentReference { _$PublicRedirectedDocumentReference(this.reference); @@ -1336,7 +1380,8 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(PublicRedirectedDocumentSnapshot._); } @@ -1348,7 +1393,7 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< final json = { ...model.toJson(), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; final castedReference = reference.withConverter>( @@ -1367,10 +1412,14 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< final json = { ...model.toJson(), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -1382,10 +1431,14 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< final json = { ...model.toJson(), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -1398,10 +1451,11 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$$PublicRedirected2ImplFieldMap['value']!: - _$$PublicRedirected2ImplPerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; return reference.update(json); @@ -1418,10 +1472,11 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$$PublicRedirected2ImplFieldMap['value']!: - _$$PublicRedirected2ImplPerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; transaction.update(reference, json); @@ -1438,10 +1493,11 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$$PublicRedirected2ImplFieldMap['value']!: - _$$PublicRedirected2ImplPerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; batch.update(reference, json); @@ -1589,17 +1645,17 @@ class _$PublicRedirectedQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(PublicRedirectedQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + PublicRedirectedQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -1656,7 +1712,8 @@ class _$PublicRedirectedQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1688,7 +1745,8 @@ class _$PublicRedirectedQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1711,34 +1769,37 @@ class _$PublicRedirectedQuery return _$PublicRedirectedQuery( _collection, $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PublicRedirected2ImplFieldMap['value']!, + _$PublicRedirected2FieldMap['value']!, isEqualTo: isEqualTo != _sentinel - ? _$$PublicRedirected2ImplPerFieldToJson.value(isEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value(isEqualTo as String) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isNotEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value(isNotEqualTo as String) : null, isLessThan: isLessThan != null - ? _$$PublicRedirected2ImplPerFieldToJson.value(isLessThan as String) + ? _$PublicRedirected2PerFieldToJson.value(isLessThan as String) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isLessThanOrEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value( + isLessThanOrEqualTo as String, + ) : null, isGreaterThan: isGreaterThan != null - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isGreaterThan as String) + ? _$PublicRedirected2PerFieldToJson.value(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isGreaterThanOrEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value( + isGreaterThanOrEqualTo as String, + ) : null, - whereIn: whereIn - ?.map((e) => _$$PublicRedirected2ImplPerFieldToJson.value(e)), - whereNotIn: whereNotIn - ?.map((e) => _$$PublicRedirected2ImplPerFieldToJson.value(e)), - isNull: isNull ?? + whereIn: whereIn?.map( + (e) => _$PublicRedirected2PerFieldToJson.value(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$PublicRedirected2PerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1759,8 +1820,10 @@ class _$PublicRedirectedQuery PublicRedirectedDocumentSnapshot? endBeforeDocument, PublicRedirectedDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1832,8 +1895,10 @@ class _$PublicRedirectedQuery PublicRedirectedDocumentSnapshot? endBeforeDocument, PublicRedirectedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1906,8 +1971,9 @@ class _$PublicRedirectedQuery PublicRedirectedDocumentSnapshot? startAfterDocument, }) { final query = $referenceWithoutCursor.orderBy( - _$$PublicRedirected2ImplFieldMap['value']!, - descending: descending); + _$PublicRedirected2FieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1937,25 +2003,37 @@ class _$PublicRedirectedQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PublicRedirected2PerFieldToJson.value(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PublicRedirected2PerFieldToJson.value(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PublicRedirected2PerFieldToJson.value(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PublicRedirected2PerFieldToJson.value(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -1987,48 +2065,40 @@ class PublicRedirectedDocumentSnapshot @override PublicRedirectedDocumentReference get reference { - return PublicRedirectedDocumentReference( - snapshot.reference, - ); + return PublicRedirectedDocumentReference(snapshot.reference); } @override final PublicRedirected? data; } -class PublicRedirectedQuerySnapshot extends FirestoreQuerySnapshot< - PublicRedirected, PublicRedirectedQueryDocumentSnapshot> { - PublicRedirectedQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class PublicRedirectedQuerySnapshot + extends + FirestoreQuerySnapshot< + PublicRedirected, + PublicRedirectedQueryDocumentSnapshot + > { + PublicRedirectedQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory PublicRedirectedQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, ) { - final docs = - snapshot.docs.map(PublicRedirectedQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(PublicRedirectedQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - PublicRedirectedDocumentSnapshot._, - ); + return _decodeDocumentChange(change, PublicRedirectedDocumentSnapshot._); }).toList(); - return PublicRedirectedQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return PublicRedirectedQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, PublicRedirectedDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, + decodeDoc, ) { return FirestoreDocumentChange( type: docChange.type, @@ -2045,14 +2115,14 @@ class PublicRedirectedQuerySnapshot extends FirestoreQuerySnapshot< @override final List> - docChanges; + docChanges; } class PublicRedirectedQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements PublicRedirectedDocumentSnapshot { PublicRedirectedQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; @@ -2066,52 +2136,1001 @@ class PublicRedirectedQueryDocumentSnapshot } } -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class SimpleFreezedCollectionReference + implements + SimpleFreezedQuery, + FirestoreCollectionReference< + SimpleFreezed, + SimpleFreezedQuerySnapshot + > { + factory SimpleFreezedCollectionReference([FirebaseFirestore? firestore]) = + _$SimpleFreezedCollectionReference; + + static SimpleFreezed fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return SimpleFreezed.fromJson(snapshot.data()!); + } + + static Map toFirestore( + SimpleFreezed value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + SimpleFreezedDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(SimpleFreezed value); +} + +class _$SimpleFreezedCollectionReference extends _$SimpleFreezedQuery + implements SimpleFreezedCollectionReference { + factory _$SimpleFreezedCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; -_$PersonImpl _$$PersonImplFromJson(Map json) => _$PersonImpl( - firstName: json['first_name'] as String, - lastName: json['LAST_NAME'] as String, + return _$SimpleFreezedCollectionReference._( + firestore + .collection('freezed-test') + .withConverter( + fromFirestore: SimpleFreezedCollectionReference.fromFirestore, + toFirestore: SimpleFreezedCollectionReference.toFirestore, + ), ); + } -const _$$PersonImplFieldMap = { - 'firstName': 'first_name', - 'lastName': 'LAST_NAME', -}; + _$SimpleFreezedCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); -// ignore: unused_element -abstract class _$$PersonImplPerFieldToJson { - // ignore: unused_element - static Object? firstName(String instance) => instance; - // ignore: unused_element - static Object? lastName(String instance) => instance; + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + SimpleFreezedDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return SimpleFreezedDocumentReference(reference.doc(id)); + } + + @override + Future add(SimpleFreezed value) { + return reference + .add(value) + .then((ref) => SimpleFreezedDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$SimpleFreezedCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class SimpleFreezedDocumentReference + extends + FirestoreDocumentReference< + SimpleFreezed, + SimpleFreezedDocumentSnapshot + > { + factory SimpleFreezedDocumentReference( + DocumentReference reference, + ) = _$SimpleFreezedDocumentReference; + + DocumentReference get reference; + + /// A reference to the [SimpleFreezedCollectionReference] containing this document. + SimpleFreezedCollectionReference get parent { + return _$SimpleFreezedCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + SimpleFreezed model, { + SetOptions? options, + FieldValue aFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + SimpleFreezed model, { + SetOptions? options, + FieldValue aFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + SimpleFreezed model, { + SetOptions? options, + FieldValue aFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({int a, FieldValue aFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + int a, + FieldValue aFieldValue, + }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate(WriteBatch batch, {int a, FieldValue aFieldValue}); } -Map _$$PersonImplToJson(_$PersonImpl instance) => - { - 'first_name': instance.firstName, - 'LAST_NAME': instance.lastName, +class _$SimpleFreezedDocumentReference + extends + FirestoreDocumentReference + implements SimpleFreezedDocumentReference { + _$SimpleFreezedDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [SimpleFreezedCollectionReference] containing this document. + SimpleFreezedCollectionReference get parent { + return _$SimpleFreezedCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(SimpleFreezedDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(SimpleFreezedDocumentSnapshot._); + } + + @override + Future transactionGet( + Transaction transaction, + ) { + return transaction.get(reference).then(SimpleFreezedDocumentSnapshot._); + } + + Future set( + SimpleFreezed model, { + SetOptions? options, + FieldValue? aFieldValue, + }) async { + final json = { + ...model.toJson(), + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, }; -_$PublicRedirected2Impl _$$PublicRedirected2ImplFromJson( - Map json) => - _$PublicRedirected2Impl( - value: json['value'] as String, + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, ); + return castedReference.set(json, options); + } -const _$$PublicRedirected2ImplFieldMap = { - 'value': 'value', -}; + void transactionSet( + Transaction transaction, + SimpleFreezed model, { + SetOptions? options, + FieldValue? aFieldValue, + }) { + final json = { + ...model.toJson(), + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, + }; -// ignore: unused_element -abstract class _$$PublicRedirected2ImplPerFieldToJson { - // ignore: unused_element - static Object? value(String instance) => instance; -} + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } -Map _$$PublicRedirected2ImplToJson( - _$PublicRedirected2Impl instance) => - { - 'value': instance.value, + void batchSet( + WriteBatch batch, + SimpleFreezed model, { + SetOptions? options, + FieldValue? aFieldValue, + }) { + final json = { + ...model.toJson(), + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({Object? a = _sentinel, FieldValue? aFieldValue}) async { + assert( + a == _sentinel || aFieldValue == null, + "Cannot specify both a and aFieldValue", + ); + final json = { + if (a != _sentinel) + _$SimpleFreezedFieldMap['a']!: _$SimpleFreezedPerFieldToJson.a( + a as int, + ), + + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + Object? a = _sentinel, + FieldValue? aFieldValue, + }) { + assert( + a == _sentinel || aFieldValue == null, + "Cannot specify both a and aFieldValue", + ); + final json = { + if (a != _sentinel) + _$SimpleFreezedFieldMap['a']!: _$SimpleFreezedPerFieldToJson.a( + a as int, + ), + + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, + }; + + transaction.update(reference, json); + } + + void batchUpdate( + WriteBatch batch, { + Object? a = _sentinel, + FieldValue? aFieldValue, + }) { + assert( + a == _sentinel || aFieldValue == null, + "Cannot specify both a and aFieldValue", + ); + final json = { + if (a != _sentinel) + _$SimpleFreezedFieldMap['a']!: _$SimpleFreezedPerFieldToJson.a( + a as int, + ), + + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, + }; + + batch.update(reference, json); + } + + @override + bool operator ==(Object other) { + return other is SimpleFreezedDocumentReference && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class SimpleFreezedQuery + implements QueryReference { + @override + SimpleFreezedQuery limit(int limit); + + @override + SimpleFreezedQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + SimpleFreezedQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + SimpleFreezedQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + SimpleFreezedQuery whereA({ + int? isEqualTo, + int? isNotEqualTo, + int? isLessThan, + int? isLessThanOrEqualTo, + int? isGreaterThan, + int? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + SimpleFreezedQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + SimpleFreezedDocumentSnapshot? startAtDocument, + SimpleFreezedDocumentSnapshot? endAtDocument, + SimpleFreezedDocumentSnapshot? endBeforeDocument, + SimpleFreezedDocumentSnapshot? startAfterDocument, + }); + + SimpleFreezedQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + SimpleFreezedDocumentSnapshot? startAtDocument, + SimpleFreezedDocumentSnapshot? endAtDocument, + SimpleFreezedDocumentSnapshot? endBeforeDocument, + SimpleFreezedDocumentSnapshot? startAfterDocument, + }); + + SimpleFreezedQuery orderByA({ + bool descending = false, + int startAt, + int startAfter, + int endAt, + int endBefore, + SimpleFreezedDocumentSnapshot? startAtDocument, + SimpleFreezedDocumentSnapshot? endAtDocument, + SimpleFreezedDocumentSnapshot? endBeforeDocument, + SimpleFreezedDocumentSnapshot? startAfterDocument, + }); +} + +class _$SimpleFreezedQuery + extends QueryReference + implements SimpleFreezedQuery { + _$SimpleFreezedQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + SimpleFreezedQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(SimpleFreezedQuerySnapshot._fromQuerySnapshot); + } + + @override + SimpleFreezedQuery limit(int limit) { + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + SimpleFreezedQuery limitToLast(int limit) { + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + SimpleFreezedQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + SimpleFreezedQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + SimpleFreezedQuery whereA({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$SimpleFreezedFieldMap['a']!, + isEqualTo: isEqualTo != _sentinel + ? _$SimpleFreezedPerFieldToJson.a(isEqualTo as int) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$SimpleFreezedPerFieldToJson.a(isNotEqualTo as int) + : null, + isLessThan: isLessThan != null + ? _$SimpleFreezedPerFieldToJson.a(isLessThan as int) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$SimpleFreezedPerFieldToJson.a(isLessThanOrEqualTo as int) + : null, + isGreaterThan: isGreaterThan != null + ? _$SimpleFreezedPerFieldToJson.a(isGreaterThan as int) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$SimpleFreezedPerFieldToJson.a(isGreaterThanOrEqualTo as int) + : null, + whereIn: whereIn?.map((e) => _$SimpleFreezedPerFieldToJson.a(e)), + whereNotIn: whereNotIn?.map((e) => _$SimpleFreezedPerFieldToJson.a(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + SimpleFreezedQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + SimpleFreezedDocumentSnapshot? startAtDocument, + SimpleFreezedDocumentSnapshot? endAtDocument, + SimpleFreezedDocumentSnapshot? endBeforeDocument, + SimpleFreezedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + SimpleFreezedQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + SimpleFreezedDocumentSnapshot? startAtDocument, + SimpleFreezedDocumentSnapshot? endAtDocument, + SimpleFreezedDocumentSnapshot? endBeforeDocument, + SimpleFreezedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + SimpleFreezedQuery orderByA({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + SimpleFreezedDocumentSnapshot? startAtDocument, + SimpleFreezedDocumentSnapshot? endAtDocument, + SimpleFreezedDocumentSnapshot? endBeforeDocument, + SimpleFreezedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$SimpleFreezedFieldMap['a']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$SimpleFreezedPerFieldToJson.a(startAt as int), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$SimpleFreezedPerFieldToJson.a(startAfter as int), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$SimpleFreezedPerFieldToJson.a(endAt as int), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$SimpleFreezedPerFieldToJson.a(endBefore as int), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$SimpleFreezedQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class SimpleFreezedDocumentSnapshot + extends FirestoreDocumentSnapshot { + SimpleFreezedDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + SimpleFreezedDocumentReference get reference { + return SimpleFreezedDocumentReference(snapshot.reference); + } + + @override + final SimpleFreezed? data; +} + +class SimpleFreezedQuerySnapshot + extends + FirestoreQuerySnapshot< + SimpleFreezed, + SimpleFreezedQueryDocumentSnapshot + > { + SimpleFreezedQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory SimpleFreezedQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(SimpleFreezedQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, SimpleFreezedDocumentSnapshot._); + }).toList(); + + return SimpleFreezedQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + SimpleFreezedDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class SimpleFreezedQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements SimpleFreezedDocumentSnapshot { + SimpleFreezedQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final SimpleFreezed data; + + @override + SimpleFreezedDocumentReference get reference { + return SimpleFreezedDocumentReference(snapshot.reference); + } +} + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +SimpleFreezed _$SimpleFreezedFromJson(Map json) => + SimpleFreezed(a: (json['a'] as num).toInt()); + +const _$SimpleFreezedFieldMap = {'a': 'a'}; + +// ignore: unused_element +abstract class _$SimpleFreezedPerFieldToJson { + // ignore: unused_element + static Object? a(int instance) => instance; +} + +Map _$SimpleFreezedToJson(SimpleFreezed instance) => + {'a': instance.a}; + +_Person _$PersonFromJson(Map json) => _Person( + firstName: json['first_name'] as String, + lastName: json['LAST_NAME'] as String, +); + +const _$PersonFieldMap = { + 'firstName': 'first_name', + 'lastName': 'LAST_NAME', +}; + +// ignore: unused_element +abstract class _$PersonPerFieldToJson { + // ignore: unused_element + static Object? firstName(String instance) => instance; + // ignore: unused_element + static Object? lastName(String instance) => instance; +} + +Map _$PersonToJson(_Person instance) => { + 'first_name': instance.firstName, + 'LAST_NAME': instance.lastName, +}; + +PublicRedirected2 _$PublicRedirected2FromJson(Map json) => + PublicRedirected2(value: json['value'] as String); + +const _$PublicRedirected2FieldMap = {'value': 'value'}; + +// ignore: unused_element +abstract class _$PublicRedirected2PerFieldToJson { + // ignore: unused_element + static Object? value(String instance) => instance; +} + +Map _$PublicRedirected2ToJson(PublicRedirected2 instance) => + {'value': instance.value}; diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.dart index 038ef41..3ff9923 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.dart +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.dart @@ -35,11 +35,7 @@ class Model { final String value; } -enum TestEnum { - one, - two, - three; -} +enum TestEnum { one, two, three } @JsonSerializable() class Nested { @@ -85,8 +81,7 @@ final nestedRef = NestedCollectionReference(); class EmptyModel { EmptyModel(); - factory EmptyModel.fromJson(Map json) => - _$EmptyModelFromJson(json); + factory EmptyModel.fromJson(Map json) => _$EmptyModelFromJson(json); Map toJson() => _$EmptyModelToJson(this); } @@ -136,8 +131,7 @@ final optionalJsonRef = OptionalJsonCollectionReference(); class MixedJson { MixedJson(this.value); - factory MixedJson.fromJson(Map json) => - MixedJson(json['foo']! as int); + factory MixedJson.fromJson(Map json) => MixedJson(json['foo']! as int); final int value; @@ -163,8 +157,7 @@ class Sub { class CustomSubName { CustomSubName(this.value); - factory CustomSubName.fromJson(Map json) => - _$CustomSubNameFromJson(json); + factory CustomSubName.fromJson(Map json) => _$CustomSubNameFromJson(json); final num value; @@ -175,8 +168,7 @@ class CustomSubName { class AsCamelCase { AsCamelCase(this.value); - factory AsCamelCase.fromJson(Map json) => - _$AsCamelCaseFromJson(json); + factory AsCamelCase.fromJson(Map json) => _$AsCamelCaseFromJson(json); final num value; @@ -199,18 +191,14 @@ class CustomClassPrefix { @Collection('root/*/sub') @Collection('root/*/as-camel-case') @Collection('root/*/custom-sub-name', name: 'thisIsACustomName') -@Collection( - 'root/*/custom-class-prefix', - prefix: 'ThisIsACustomPrefix', -) +@Collection('root/*/custom-class-prefix', prefix: 'ThisIsACustomPrefix') final rootRef = RootCollectionReference(); @JsonSerializable() class ExplicitPath { ExplicitPath(this.value); - factory ExplicitPath.fromJson(Map json) => - _$ExplicitPathFromJson(json); + factory ExplicitPath.fromJson(Map json) => _$ExplicitPathFromJson(json); final num value; @@ -221,8 +209,7 @@ class ExplicitPath { class ExplicitSubPath { ExplicitSubPath(this.value); - factory ExplicitSubPath.fromJson(Map json) => - _$ExplicitSubPathFromJson(json); + factory ExplicitSubPath.fromJson(Map json) => _$ExplicitSubPathFromJson(json); final num value; @@ -244,8 +231,7 @@ abstract class BaseClass { class SubClass extends BaseClass { SubClass(super.instanceGetter); - factory SubClass.fromJson(Map json) => - _$SubClassFromJson(json); + factory SubClass.fromJson(Map json) => _$SubClassFromJson(json); Map toJson() => _$SubClassToJson(this); } diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.g.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.g.dart index e4b949b..f70e1fc 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.g.dart +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.g.dart @@ -23,11 +23,12 @@ const _sentinel = _Sentinel(); abstract class IgnoredGetterCollectionReference implements IgnoredGetterQuery, - FirestoreCollectionReference { - factory IgnoredGetterCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$IgnoredGetterCollectionReference; + FirestoreCollectionReference< + IgnoredGetter, + IgnoredGetterQuerySnapshot + > { + factory IgnoredGetterCollectionReference([FirebaseFirestore? firestore]) = + _$IgnoredGetterCollectionReference; static IgnoredGetter fromFirestore( DocumentSnapshot> snapshot, @@ -60,7 +61,9 @@ class _$IgnoredGetterCollectionReference extends _$IgnoredGetterQuery firestore ??= FirebaseFirestore.instance; return _$IgnoredGetterCollectionReference._( - firestore.collection('firestore-example-app/test/getter').withConverter( + firestore + .collection('firestore-example-app/test/getter') + .withConverter( fromFirestore: IgnoredGetterCollectionReference.fromFirestore, toFirestore: IgnoredGetterCollectionReference.toFirestore, ), @@ -83,9 +86,7 @@ class _$IgnoredGetterCollectionReference extends _$IgnoredGetterQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return IgnoredGetterDocumentReference( - reference.doc(id), - ); + return IgnoredGetterDocumentReference(reference.doc(id)); } @override @@ -107,11 +108,14 @@ class _$IgnoredGetterCollectionReference extends _$IgnoredGetterQuery } abstract class IgnoredGetterDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + IgnoredGetter, + IgnoredGetterDocumentSnapshot + > { factory IgnoredGetterDocumentReference( - DocumentReference reference) = - _$IgnoredGetterDocumentReference; + DocumentReference reference, + ) = _$IgnoredGetterDocumentReference; DocumentReference get reference; @@ -175,10 +179,7 @@ abstract class IgnoredGetterDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - int value, - FieldValue valueFieldValue, - }); + Future update({int value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -192,16 +193,13 @@ abstract class IgnoredGetterDocumentReference /// Updates fields in the current document using the batch API. /// /// The update will fail if applied to a document that does not exist. - void batchUpdate( - WriteBatch batch, { - int value, - FieldValue valueFieldValue, - }); + void batchUpdate(WriteBatch batch, {int value, FieldValue valueFieldValue}); } -class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< - IgnoredGetter, - IgnoredGetterDocumentSnapshot> implements IgnoredGetterDocumentReference { +class _$IgnoredGetterDocumentReference + extends + FirestoreDocumentReference + implements IgnoredGetterDocumentReference { _$IgnoredGetterDocumentReference(this.reference); @override @@ -224,7 +222,8 @@ class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(IgnoredGetterDocumentSnapshot._); } @@ -258,7 +257,11 @@ class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< _$IgnoredGetterFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -273,7 +276,11 @@ class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< _$IgnoredGetterFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -286,8 +293,10 @@ class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$IgnoredGetterFieldMap['value']!: - _$IgnoredGetterPerFieldToJson.value(value as int), + _$IgnoredGetterFieldMap['value']!: _$IgnoredGetterPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$IgnoredGetterFieldMap['value']!: valueFieldValue, }; @@ -306,8 +315,10 @@ class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$IgnoredGetterFieldMap['value']!: - _$IgnoredGetterPerFieldToJson.value(value as int), + _$IgnoredGetterFieldMap['value']!: _$IgnoredGetterPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$IgnoredGetterFieldMap['value']!: valueFieldValue, }; @@ -326,8 +337,10 @@ class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$IgnoredGetterFieldMap['value']!: - _$IgnoredGetterPerFieldToJson.value(value as int), + _$IgnoredGetterFieldMap['value']!: _$IgnoredGetterPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$IgnoredGetterFieldMap['value']!: valueFieldValue, }; @@ -477,17 +490,17 @@ class _$IgnoredGetterQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(IgnoredGetterQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + IgnoredGetterQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -544,7 +557,8 @@ class _$IgnoredGetterQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -576,7 +590,8 @@ class _$IgnoredGetterQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -619,9 +634,11 @@ class _$IgnoredGetterQuery ? _$IgnoredGetterPerFieldToJson.value(isGreaterThanOrEqualTo as int) : null, whereIn: whereIn?.map((e) => _$IgnoredGetterPerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$IgnoredGetterPerFieldToJson.value(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$IgnoredGetterPerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -642,8 +659,10 @@ class _$IgnoredGetterQuery IgnoredGetterDocumentSnapshot? endBeforeDocument, IgnoredGetterDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -715,8 +734,10 @@ class _$IgnoredGetterQuery IgnoredGetterDocumentSnapshot? endBeforeDocument, IgnoredGetterDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -788,8 +809,10 @@ class _$IgnoredGetterQuery IgnoredGetterDocumentSnapshot? endBeforeDocument, IgnoredGetterDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$IgnoredGetterFieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$IgnoredGetterFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -819,25 +842,37 @@ class _$IgnoredGetterQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$IgnoredGetterPerFieldToJson.value(startAt as int), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$IgnoredGetterPerFieldToJson.value(startAfter as int), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$IgnoredGetterPerFieldToJson.value(endAt as int), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$IgnoredGetterPerFieldToJson.value(endBefore as int), + ], endBeforeDocumentSnapshot: null, ); } @@ -869,45 +904,37 @@ class IgnoredGetterDocumentSnapshot @override IgnoredGetterDocumentReference get reference { - return IgnoredGetterDocumentReference( - snapshot.reference, - ); + return IgnoredGetterDocumentReference(snapshot.reference); } @override final IgnoredGetter? data; } -class IgnoredGetterQuerySnapshot extends FirestoreQuerySnapshot { - IgnoredGetterQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class IgnoredGetterQuerySnapshot + extends + FirestoreQuerySnapshot< + IgnoredGetter, + IgnoredGetterQueryDocumentSnapshot + > { + IgnoredGetterQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory IgnoredGetterQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, ) { - final docs = - snapshot.docs.map(IgnoredGetterQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(IgnoredGetterQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - IgnoredGetterDocumentSnapshot._, - ); + return _decodeDocumentChange(change, IgnoredGetterDocumentSnapshot._); }).toList(); - return IgnoredGetterQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return IgnoredGetterQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, IgnoredGetterDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -952,9 +979,8 @@ abstract class ModelCollectionReference implements ModelQuery, FirestoreCollectionReference { - factory ModelCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$ModelCollectionReference; + factory ModelCollectionReference([FirebaseFirestore? firestore]) = + _$ModelCollectionReference; static Model fromFirestore( DocumentSnapshot> snapshot, @@ -963,10 +989,7 @@ abstract class ModelCollectionReference return _$ModelFromJson(snapshot.data()!); } - static Map toFirestore( - Model value, - SetOptions? options, - ) { + static Map toFirestore(Model value, SetOptions? options) { return _$ModelToJson(value); } @@ -987,16 +1010,17 @@ class _$ModelCollectionReference extends _$ModelQuery firestore ??= FirebaseFirestore.instance; return _$ModelCollectionReference._( - firestore.collection('root').withConverter( + firestore + .collection('root') + .withConverter( fromFirestore: ModelCollectionReference.fromFirestore, toFirestore: ModelCollectionReference.toFirestore, ), ); } - _$ModelCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$ModelCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -1010,9 +1034,7 @@ class _$ModelCollectionReference extends _$ModelQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return ModelDocumentReference( - reference.doc(id), - ); + return ModelDocumentReference(reference.doc(id)); } @override @@ -1098,10 +1120,7 @@ abstract class ModelDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - String value, - FieldValue valueFieldValue, - }); + Future update({String value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -1178,7 +1197,11 @@ class _$ModelDocumentReference if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -1192,7 +1215,11 @@ class _$ModelDocumentReference if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -1206,6 +1233,7 @@ class _$ModelDocumentReference final json = { if (value != _sentinel) _$ModelFieldMap['value']!: _$ModelPerFieldToJson.value(value as String), + if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, }; @@ -1224,6 +1252,7 @@ class _$ModelDocumentReference final json = { if (value != _sentinel) _$ModelFieldMap['value']!: _$ModelPerFieldToJson.value(value as String), + if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, }; @@ -1242,6 +1271,7 @@ class _$ModelDocumentReference final json = { if (value != _sentinel) _$ModelFieldMap['value']!: _$ModelPerFieldToJson.value(value as String), + if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, }; @@ -1388,9 +1418,9 @@ class _$ModelQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -1451,7 +1481,8 @@ class _$ModelQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1483,7 +1514,8 @@ class _$ModelQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1527,7 +1559,8 @@ class _$ModelQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$ModelPerFieldToJson.value(e)), whereNotIn: whereNotIn?.map((e) => _$ModelPerFieldToJson.value(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1548,8 +1581,10 @@ class _$ModelQuery extends QueryReference ModelDocumentSnapshot? endBeforeDocument, ModelDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1621,8 +1656,10 @@ class _$ModelQuery extends QueryReference ModelDocumentSnapshot? endBeforeDocument, ModelDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1694,8 +1731,10 @@ class _$ModelQuery extends QueryReference ModelDocumentSnapshot? endBeforeDocument, ModelDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$ModelFieldMap['value']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$ModelFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1725,25 +1764,37 @@ class _$ModelQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$ModelPerFieldToJson.value(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$ModelPerFieldToJson.value(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$ModelPerFieldToJson.value(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$ModelPerFieldToJson.value(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -1774,9 +1825,7 @@ class ModelDocumentSnapshot extends FirestoreDocumentSnapshot { @override ModelDocumentReference get reference { - return ModelDocumentReference( - snapshot.reference, - ); + return ModelDocumentReference(snapshot.reference); } @override @@ -1785,33 +1834,20 @@ class ModelDocumentSnapshot extends FirestoreDocumentSnapshot { class ModelQuerySnapshot extends FirestoreQuerySnapshot { - ModelQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory ModelQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { + ModelQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory ModelQuerySnapshot._fromQuerySnapshot(QuerySnapshot snapshot) { final docs = snapshot.docs.map(ModelQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - ModelDocumentSnapshot._, - ); + return _decodeDocumentChange(change, ModelDocumentSnapshot._); }).toList(); - return ModelQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return ModelQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, ModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -1855,9 +1891,8 @@ abstract class NestedCollectionReference implements NestedQuery, FirestoreCollectionReference { - factory NestedCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$NestedCollectionReference; + factory NestedCollectionReference([FirebaseFirestore? firestore]) = + _$NestedCollectionReference; static Nested fromFirestore( DocumentSnapshot> snapshot, @@ -1866,10 +1901,7 @@ abstract class NestedCollectionReference return Nested.fromJson(snapshot.data()!); } - static Map toFirestore( - Nested value, - SetOptions? options, - ) { + static Map toFirestore(Nested value, SetOptions? options) { return value.toJson(); } @@ -1890,16 +1922,17 @@ class _$NestedCollectionReference extends _$NestedQuery firestore ??= FirebaseFirestore.instance; return _$NestedCollectionReference._( - firestore.collection('nested').withConverter( + firestore + .collection('nested') + .withConverter( fromFirestore: NestedCollectionReference.fromFirestore, toFirestore: NestedCollectionReference.toFirestore, ), ); } - _$NestedCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$NestedCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -1913,9 +1946,7 @@ class _$NestedCollectionReference extends _$NestedQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return NestedDocumentReference( - reference.doc(id), - ); + return NestedDocumentReference(reference.doc(id)); } @override @@ -2181,28 +2212,40 @@ class _$NestedDocumentReference final json = { ...model.toJson(), if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, + if (simpleFieldValue != null) _$NestedFieldMap['simple']!: simpleFieldValue, + if (valueListFieldValue != null) _$NestedFieldMap['valueList']!: valueListFieldValue, + if (boolListFieldValue != null) _$NestedFieldMap['boolList']!: boolListFieldValue, + if (stringListFieldValue != null) _$NestedFieldMap['stringList']!: stringListFieldValue, + if (numListFieldValue != null) _$NestedFieldMap['numList']!: numListFieldValue, + if (objectListFieldValue != null) _$NestedFieldMap['objectList']!: objectListFieldValue, + if (dynamicListFieldValue != null) _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, + if (boolSetFieldValue != null) _$NestedFieldMap['boolSet']!: boolSetFieldValue, + if (enumValueFieldValue != null) _$NestedFieldMap['enumValue']!: enumValueFieldValue, + if (nullableEnumValueFieldValue != null) _$NestedFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + if (enumListFieldValue != null) _$NestedFieldMap['enumList']!: enumListFieldValue, + if (nullableEnumListFieldValue != null) _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; @@ -2235,33 +2278,49 @@ class _$NestedDocumentReference final json = { ...model.toJson(), if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, + if (simpleFieldValue != null) _$NestedFieldMap['simple']!: simpleFieldValue, + if (valueListFieldValue != null) _$NestedFieldMap['valueList']!: valueListFieldValue, + if (boolListFieldValue != null) _$NestedFieldMap['boolList']!: boolListFieldValue, + if (stringListFieldValue != null) _$NestedFieldMap['stringList']!: stringListFieldValue, + if (numListFieldValue != null) _$NestedFieldMap['numList']!: numListFieldValue, + if (objectListFieldValue != null) _$NestedFieldMap['objectList']!: objectListFieldValue, + if (dynamicListFieldValue != null) _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, + if (boolSetFieldValue != null) _$NestedFieldMap['boolSet']!: boolSetFieldValue, + if (enumValueFieldValue != null) _$NestedFieldMap['enumValue']!: enumValueFieldValue, + if (nullableEnumValueFieldValue != null) _$NestedFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + if (enumListFieldValue != null) _$NestedFieldMap['enumList']!: enumListFieldValue, + if (nullableEnumListFieldValue != null) _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -2285,33 +2344,49 @@ class _$NestedDocumentReference final json = { ...model.toJson(), if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, + if (simpleFieldValue != null) _$NestedFieldMap['simple']!: simpleFieldValue, + if (valueListFieldValue != null) _$NestedFieldMap['valueList']!: valueListFieldValue, + if (boolListFieldValue != null) _$NestedFieldMap['boolList']!: boolListFieldValue, + if (stringListFieldValue != null) _$NestedFieldMap['stringList']!: stringListFieldValue, + if (numListFieldValue != null) _$NestedFieldMap['numList']!: numListFieldValue, + if (objectListFieldValue != null) _$NestedFieldMap['objectList']!: objectListFieldValue, + if (dynamicListFieldValue != null) _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, + if (boolSetFieldValue != null) _$NestedFieldMap['boolSet']!: boolSetFieldValue, + if (enumValueFieldValue != null) _$NestedFieldMap['enumValue']!: enumValueFieldValue, + if (nullableEnumValueFieldValue != null) _$NestedFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + if (enumListFieldValue != null) _$NestedFieldMap['enumList']!: enumListFieldValue, + if (nullableEnumListFieldValue != null) _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -2396,67 +2471,103 @@ class _$NestedDocumentReference ); final json = { if (value != _sentinel) - _$NestedFieldMap['value']!: - _$NestedPerFieldToJson.value(value as Nested?), + _$NestedFieldMap['value']!: _$NestedPerFieldToJson.value( + value as Nested?, + ), + if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, + if (simple != _sentinel) - _$NestedFieldMap['simple']!: - _$NestedPerFieldToJson.simple(simple as int?), + _$NestedFieldMap['simple']!: _$NestedPerFieldToJson.simple( + simple as int?, + ), + if (simpleFieldValue != null) _$NestedFieldMap['simple']!: simpleFieldValue, + if (valueList != _sentinel) - _$NestedFieldMap['valueList']!: - _$NestedPerFieldToJson.valueList(valueList as List?), + _$NestedFieldMap['valueList']!: _$NestedPerFieldToJson.valueList( + valueList as List?, + ), + if (valueListFieldValue != null) _$NestedFieldMap['valueList']!: valueListFieldValue, + if (boolList != _sentinel) - _$NestedFieldMap['boolList']!: - _$NestedPerFieldToJson.boolList(boolList as List?), + _$NestedFieldMap['boolList']!: _$NestedPerFieldToJson.boolList( + boolList as List?, + ), + if (boolListFieldValue != null) _$NestedFieldMap['boolList']!: boolListFieldValue, + if (stringList != _sentinel) - _$NestedFieldMap['stringList']!: - _$NestedPerFieldToJson.stringList(stringList as List?), + _$NestedFieldMap['stringList']!: _$NestedPerFieldToJson.stringList( + stringList as List?, + ), + if (stringListFieldValue != null) _$NestedFieldMap['stringList']!: stringListFieldValue, + if (numList != _sentinel) - _$NestedFieldMap['numList']!: - _$NestedPerFieldToJson.numList(numList as List?), + _$NestedFieldMap['numList']!: _$NestedPerFieldToJson.numList( + numList as List?, + ), + if (numListFieldValue != null) _$NestedFieldMap['numList']!: numListFieldValue, + if (objectList != _sentinel) - _$NestedFieldMap['objectList']!: - _$NestedPerFieldToJson.objectList(objectList as List?), + _$NestedFieldMap['objectList']!: _$NestedPerFieldToJson.objectList( + objectList as List?, + ), + if (objectListFieldValue != null) _$NestedFieldMap['objectList']!: objectListFieldValue, + if (dynamicList != _sentinel) - _$NestedFieldMap['dynamicList']!: - _$NestedPerFieldToJson.dynamicList(dynamicList as List?), + _$NestedFieldMap['dynamicList']!: _$NestedPerFieldToJson.dynamicList( + dynamicList as List?, + ), + if (dynamicListFieldValue != null) _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, + if (boolSet != _sentinel) - _$NestedFieldMap['boolSet']!: - _$NestedPerFieldToJson.boolSet(boolSet as Set?), + _$NestedFieldMap['boolSet']!: _$NestedPerFieldToJson.boolSet( + boolSet as Set?, + ), + if (boolSetFieldValue != null) _$NestedFieldMap['boolSet']!: boolSetFieldValue, + if (enumValue != _sentinel) - _$NestedFieldMap['enumValue']!: - _$NestedPerFieldToJson.enumValue(enumValue as TestEnum), + _$NestedFieldMap['enumValue']!: _$NestedPerFieldToJson.enumValue( + enumValue as TestEnum, + ), + if (enumValueFieldValue != null) _$NestedFieldMap['enumValue']!: enumValueFieldValue, + if (nullableEnumValue != _sentinel) _$NestedFieldMap['nullableEnumValue']!: _$NestedPerFieldToJson .nullableEnumValue(nullableEnumValue as TestEnum?), + if (nullableEnumValueFieldValue != null) _$NestedFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + if (enumList != _sentinel) - _$NestedFieldMap['enumList']!: - _$NestedPerFieldToJson.enumList(enumList as List), + _$NestedFieldMap['enumList']!: _$NestedPerFieldToJson.enumList( + enumList as List, + ), + if (enumListFieldValue != null) _$NestedFieldMap['enumList']!: enumListFieldValue, + if (nullableEnumList != _sentinel) _$NestedFieldMap['nullableEnumList']!: _$NestedPerFieldToJson .nullableEnumList(nullableEnumList as List?), + if (nullableEnumListFieldValue != null) _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; @@ -2547,67 +2658,103 @@ class _$NestedDocumentReference ); final json = { if (value != _sentinel) - _$NestedFieldMap['value']!: - _$NestedPerFieldToJson.value(value as Nested?), + _$NestedFieldMap['value']!: _$NestedPerFieldToJson.value( + value as Nested?, + ), + if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, + if (simple != _sentinel) - _$NestedFieldMap['simple']!: - _$NestedPerFieldToJson.simple(simple as int?), + _$NestedFieldMap['simple']!: _$NestedPerFieldToJson.simple( + simple as int?, + ), + if (simpleFieldValue != null) _$NestedFieldMap['simple']!: simpleFieldValue, + if (valueList != _sentinel) - _$NestedFieldMap['valueList']!: - _$NestedPerFieldToJson.valueList(valueList as List?), + _$NestedFieldMap['valueList']!: _$NestedPerFieldToJson.valueList( + valueList as List?, + ), + if (valueListFieldValue != null) _$NestedFieldMap['valueList']!: valueListFieldValue, + if (boolList != _sentinel) - _$NestedFieldMap['boolList']!: - _$NestedPerFieldToJson.boolList(boolList as List?), + _$NestedFieldMap['boolList']!: _$NestedPerFieldToJson.boolList( + boolList as List?, + ), + if (boolListFieldValue != null) _$NestedFieldMap['boolList']!: boolListFieldValue, + if (stringList != _sentinel) - _$NestedFieldMap['stringList']!: - _$NestedPerFieldToJson.stringList(stringList as List?), + _$NestedFieldMap['stringList']!: _$NestedPerFieldToJson.stringList( + stringList as List?, + ), + if (stringListFieldValue != null) _$NestedFieldMap['stringList']!: stringListFieldValue, + if (numList != _sentinel) - _$NestedFieldMap['numList']!: - _$NestedPerFieldToJson.numList(numList as List?), + _$NestedFieldMap['numList']!: _$NestedPerFieldToJson.numList( + numList as List?, + ), + if (numListFieldValue != null) _$NestedFieldMap['numList']!: numListFieldValue, + if (objectList != _sentinel) - _$NestedFieldMap['objectList']!: - _$NestedPerFieldToJson.objectList(objectList as List?), + _$NestedFieldMap['objectList']!: _$NestedPerFieldToJson.objectList( + objectList as List?, + ), + if (objectListFieldValue != null) _$NestedFieldMap['objectList']!: objectListFieldValue, + if (dynamicList != _sentinel) - _$NestedFieldMap['dynamicList']!: - _$NestedPerFieldToJson.dynamicList(dynamicList as List?), + _$NestedFieldMap['dynamicList']!: _$NestedPerFieldToJson.dynamicList( + dynamicList as List?, + ), + if (dynamicListFieldValue != null) _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, + if (boolSet != _sentinel) - _$NestedFieldMap['boolSet']!: - _$NestedPerFieldToJson.boolSet(boolSet as Set?), + _$NestedFieldMap['boolSet']!: _$NestedPerFieldToJson.boolSet( + boolSet as Set?, + ), + if (boolSetFieldValue != null) _$NestedFieldMap['boolSet']!: boolSetFieldValue, + if (enumValue != _sentinel) - _$NestedFieldMap['enumValue']!: - _$NestedPerFieldToJson.enumValue(enumValue as TestEnum), + _$NestedFieldMap['enumValue']!: _$NestedPerFieldToJson.enumValue( + enumValue as TestEnum, + ), + if (enumValueFieldValue != null) _$NestedFieldMap['enumValue']!: enumValueFieldValue, + if (nullableEnumValue != _sentinel) _$NestedFieldMap['nullableEnumValue']!: _$NestedPerFieldToJson .nullableEnumValue(nullableEnumValue as TestEnum?), + if (nullableEnumValueFieldValue != null) _$NestedFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + if (enumList != _sentinel) - _$NestedFieldMap['enumList']!: - _$NestedPerFieldToJson.enumList(enumList as List), + _$NestedFieldMap['enumList']!: _$NestedPerFieldToJson.enumList( + enumList as List, + ), + if (enumListFieldValue != null) _$NestedFieldMap['enumList']!: enumListFieldValue, + if (nullableEnumList != _sentinel) _$NestedFieldMap['nullableEnumList']!: _$NestedPerFieldToJson .nullableEnumList(nullableEnumList as List?), + if (nullableEnumListFieldValue != null) _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; @@ -2698,67 +2845,103 @@ class _$NestedDocumentReference ); final json = { if (value != _sentinel) - _$NestedFieldMap['value']!: - _$NestedPerFieldToJson.value(value as Nested?), + _$NestedFieldMap['value']!: _$NestedPerFieldToJson.value( + value as Nested?, + ), + if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, + if (simple != _sentinel) - _$NestedFieldMap['simple']!: - _$NestedPerFieldToJson.simple(simple as int?), + _$NestedFieldMap['simple']!: _$NestedPerFieldToJson.simple( + simple as int?, + ), + if (simpleFieldValue != null) _$NestedFieldMap['simple']!: simpleFieldValue, + if (valueList != _sentinel) - _$NestedFieldMap['valueList']!: - _$NestedPerFieldToJson.valueList(valueList as List?), + _$NestedFieldMap['valueList']!: _$NestedPerFieldToJson.valueList( + valueList as List?, + ), + if (valueListFieldValue != null) _$NestedFieldMap['valueList']!: valueListFieldValue, + if (boolList != _sentinel) - _$NestedFieldMap['boolList']!: - _$NestedPerFieldToJson.boolList(boolList as List?), + _$NestedFieldMap['boolList']!: _$NestedPerFieldToJson.boolList( + boolList as List?, + ), + if (boolListFieldValue != null) _$NestedFieldMap['boolList']!: boolListFieldValue, + if (stringList != _sentinel) - _$NestedFieldMap['stringList']!: - _$NestedPerFieldToJson.stringList(stringList as List?), + _$NestedFieldMap['stringList']!: _$NestedPerFieldToJson.stringList( + stringList as List?, + ), + if (stringListFieldValue != null) _$NestedFieldMap['stringList']!: stringListFieldValue, + if (numList != _sentinel) - _$NestedFieldMap['numList']!: - _$NestedPerFieldToJson.numList(numList as List?), + _$NestedFieldMap['numList']!: _$NestedPerFieldToJson.numList( + numList as List?, + ), + if (numListFieldValue != null) _$NestedFieldMap['numList']!: numListFieldValue, + if (objectList != _sentinel) - _$NestedFieldMap['objectList']!: - _$NestedPerFieldToJson.objectList(objectList as List?), + _$NestedFieldMap['objectList']!: _$NestedPerFieldToJson.objectList( + objectList as List?, + ), + if (objectListFieldValue != null) _$NestedFieldMap['objectList']!: objectListFieldValue, + if (dynamicList != _sentinel) - _$NestedFieldMap['dynamicList']!: - _$NestedPerFieldToJson.dynamicList(dynamicList as List?), + _$NestedFieldMap['dynamicList']!: _$NestedPerFieldToJson.dynamicList( + dynamicList as List?, + ), + if (dynamicListFieldValue != null) _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, + if (boolSet != _sentinel) - _$NestedFieldMap['boolSet']!: - _$NestedPerFieldToJson.boolSet(boolSet as Set?), + _$NestedFieldMap['boolSet']!: _$NestedPerFieldToJson.boolSet( + boolSet as Set?, + ), + if (boolSetFieldValue != null) _$NestedFieldMap['boolSet']!: boolSetFieldValue, + if (enumValue != _sentinel) - _$NestedFieldMap['enumValue']!: - _$NestedPerFieldToJson.enumValue(enumValue as TestEnum), + _$NestedFieldMap['enumValue']!: _$NestedPerFieldToJson.enumValue( + enumValue as TestEnum, + ), + if (enumValueFieldValue != null) _$NestedFieldMap['enumValue']!: enumValueFieldValue, + if (nullableEnumValue != _sentinel) _$NestedFieldMap['nullableEnumValue']!: _$NestedPerFieldToJson .nullableEnumValue(nullableEnumValue as TestEnum?), + if (nullableEnumValueFieldValue != null) _$NestedFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + if (enumList != _sentinel) - _$NestedFieldMap['enumList']!: - _$NestedPerFieldToJson.enumList(enumList as List), + _$NestedFieldMap['enumList']!: _$NestedPerFieldToJson.enumList( + enumList as List, + ), + if (enumListFieldValue != null) _$NestedFieldMap['enumList']!: enumListFieldValue, + if (nullableEnumList != _sentinel) _$NestedFieldMap['nullableEnumList']!: _$NestedPerFieldToJson .nullableEnumList(nullableEnumList as List?), + if (nullableEnumListFieldValue != null) _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; @@ -3195,9 +3378,9 @@ class _$NestedQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -3258,7 +3441,8 @@ class _$NestedQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3290,7 +3474,8 @@ class _$NestedQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3334,7 +3519,8 @@ class _$NestedQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$NestedPerFieldToJson.value(e)), whereNotIn: whereNotIn?.map((e) => _$NestedPerFieldToJson.value(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3378,7 +3564,8 @@ class _$NestedQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$NestedPerFieldToJson.simple(e)), whereNotIn: whereNotIn?.map((e) => _$NestedPerFieldToJson.simple(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3412,26 +3599,29 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.valueList(isLessThan as List?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .valueList(isLessThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.valueList( + isLessThanOrEqualTo as List?, + ) : null, isGreaterThan: isGreaterThan != null ? _$NestedPerFieldToJson.valueList(isGreaterThan as List?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .valueList(isGreaterThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.valueList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.valueList([arrayContains as Nested]) - as List?)! - .single + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.valueList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3465,26 +3655,29 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.boolList(isLessThan as List?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .boolList(isLessThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.boolList( + isLessThanOrEqualTo as List?, + ) : null, isGreaterThan: isGreaterThan != null ? _$NestedPerFieldToJson.boolList(isGreaterThan as List?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .boolList(isGreaterThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.boolList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.boolList([arrayContains as bool]) - as List?)! - .single + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.boolList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3518,26 +3711,29 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.stringList(isLessThan as List?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .stringList(isLessThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.stringList( + isLessThanOrEqualTo as List?, + ) : null, isGreaterThan: isGreaterThan != null ? _$NestedPerFieldToJson.stringList(isGreaterThan as List?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .stringList(isGreaterThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.stringList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.stringList([arrayContains as String]) - as List?)! - .single + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.stringList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3577,18 +3773,20 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.numList(isGreaterThan as List?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .numList(isGreaterThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.numList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.numList([arrayContains as num]) as List?)! - .single + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.numList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3622,25 +3820,28 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.objectList(isLessThan as List?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .objectList(isLessThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.objectList( + isLessThanOrEqualTo as List?, + ) : null, isGreaterThan: isGreaterThan != null ? _$NestedPerFieldToJson.objectList(isGreaterThan as List?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .objectList(isGreaterThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.objectList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.objectList([arrayContains]) as List?)! - .single + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.objectList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3674,27 +3875,31 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.dynamicList(isLessThan as List?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .dynamicList(isLessThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.dynamicList( + isLessThanOrEqualTo as List?, + ) : null, isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson - .dynamicList(isGreaterThan as List?) + ? _$NestedPerFieldToJson.dynamicList( + isGreaterThan as List?, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .dynamicList(isGreaterThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.dynamicList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.dynamicList([arrayContains as dynamic]) - as List?)! - .single + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.dynamicList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3734,19 +3939,21 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.boolSet(isGreaterThan as Set?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .boolSet(isGreaterThanOrEqualTo as Set?) + ? _$NestedPerFieldToJson.boolSet( + isGreaterThanOrEqualTo as Set?, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.boolSet({arrayContains as bool}) - as List?)! - .single + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.boolSet(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3786,12 +3993,14 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.enumValue(isGreaterThan as TestEnum) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .enumValue(isGreaterThanOrEqualTo as TestEnum) + ? _$NestedPerFieldToJson.enumValue( + isGreaterThanOrEqualTo as TestEnum, + ) : null, whereIn: whereIn?.map((e) => _$NestedPerFieldToJson.enumValue(e)), whereNotIn: whereNotIn?.map((e) => _$NestedPerFieldToJson.enumValue(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3819,29 +4028,36 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.nullableEnumValue(isEqualTo as TestEnum?) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson - .nullableEnumValue(isNotEqualTo as TestEnum?) + ? _$NestedPerFieldToJson.nullableEnumValue( + isNotEqualTo as TestEnum?, + ) : null, isLessThan: isLessThan != null ? _$NestedPerFieldToJson.nullableEnumValue(isLessThan as TestEnum?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .nullableEnumValue(isLessThanOrEqualTo as TestEnum?) + ? _$NestedPerFieldToJson.nullableEnumValue( + isLessThanOrEqualTo as TestEnum?, + ) : null, isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson - .nullableEnumValue(isGreaterThan as TestEnum?) + ? _$NestedPerFieldToJson.nullableEnumValue( + isGreaterThan as TestEnum?, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .nullableEnumValue(isGreaterThanOrEqualTo as TestEnum?) - : null, - whereIn: - whereIn?.map((e) => _$NestedPerFieldToJson.nullableEnumValue(e)), - whereNotIn: - whereNotIn?.map((e) => _$NestedPerFieldToJson.nullableEnumValue(e)), - isNull: isNull ?? + ? _$NestedPerFieldToJson.nullableEnumValue( + isGreaterThanOrEqualTo as TestEnum?, + ) + : null, + whereIn: whereIn?.map( + (e) => _$NestedPerFieldToJson.nullableEnumValue(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$NestedPerFieldToJson.nullableEnumValue(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3875,26 +4091,29 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.enumList(isLessThan as List) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .enumList(isLessThanOrEqualTo as List) + ? _$NestedPerFieldToJson.enumList( + isLessThanOrEqualTo as List, + ) : null, isGreaterThan: isGreaterThan != null ? _$NestedPerFieldToJson.enumList(isGreaterThan as List) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .enumList(isGreaterThanOrEqualTo as List) + ? _$NestedPerFieldToJson.enumList( + isGreaterThanOrEqualTo as List, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.enumList([arrayContains as TestEnum]) - as List?)! - .single + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.enumList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3919,39 +4138,48 @@ class _$NestedQuery extends QueryReference $referenceWithoutCursor: $referenceWithoutCursor.where( _$NestedFieldMap['nullableEnumList']!, isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson - .nullableEnumList(isEqualTo as List?) + ? _$NestedPerFieldToJson.nullableEnumList( + isEqualTo as List?, + ) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson - .nullableEnumList(isNotEqualTo as List?) + ? _$NestedPerFieldToJson.nullableEnumList( + isNotEqualTo as List?, + ) : null, isLessThan: isLessThan != null - ? _$NestedPerFieldToJson - .nullableEnumList(isLessThan as List?) + ? _$NestedPerFieldToJson.nullableEnumList( + isLessThan as List?, + ) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .nullableEnumList(isLessThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.nullableEnumList( + isLessThanOrEqualTo as List?, + ) : null, isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson - .nullableEnumList(isGreaterThan as List?) + ? _$NestedPerFieldToJson.nullableEnumList( + isGreaterThan as List?, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .nullableEnumList(isGreaterThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.nullableEnumList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null - ? (_$NestedPerFieldToJson - .nullableEnumList([arrayContains as TestEnum]) as List?)! - .single + ? (_$NestedPerFieldToJson.nullableEnumList([ + arrayContains as TestEnum, + ]) + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.nullableEnumList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3972,8 +4200,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4045,8 +4275,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4118,8 +4350,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['value']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4149,25 +4383,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.value(startAt as Nested?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.value(startAfter as Nested?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.value(endAt as Nested?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.value(endBefore as Nested?), + ], endBeforeDocumentSnapshot: null, ); } @@ -4191,8 +4437,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['simple']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['simple']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4222,25 +4470,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.simple(startAt as int?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.simple(startAfter as int?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.simple(endAt as int?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.simple(endBefore as int?), + ], endBeforeDocumentSnapshot: null, ); } @@ -4264,8 +4524,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['valueList']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['valueList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4295,25 +4557,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.valueList(startAt as List?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.valueList(startAfter as List?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.valueList(endAt as List?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.valueList(endBefore as List?), + ], endBeforeDocumentSnapshot: null, ); } @@ -4337,8 +4611,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['boolList']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['boolList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4368,25 +4644,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.boolList(startAt as List?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.boolList(startAfter as List?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.boolList(endAt as List?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.boolList(endBefore as List?), + ], endBeforeDocumentSnapshot: null, ); } @@ -4410,8 +4698,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['stringList']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['stringList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4441,25 +4731,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.stringList(startAt as List?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.stringList(startAfter as List?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.stringList(endAt as List?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.stringList(endBefore as List?), + ], endBeforeDocumentSnapshot: null, ); } @@ -4483,8 +4785,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['numList']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['numList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4514,25 +4818,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.numList(startAt as List?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.numList(startAfter as List?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.numList(endAt as List?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.numList(endBefore as List?), + ], endBeforeDocumentSnapshot: null, ); } @@ -4556,8 +4872,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['objectList']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['objectList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4587,25 +4905,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.objectList(startAt as List?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.objectList(startAfter as List?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.objectList(endAt as List?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.objectList(endBefore as List?), + ], endBeforeDocumentSnapshot: null, ); } @@ -4629,8 +4959,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['dynamicList']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['dynamicList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4660,25 +4992,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.dynamicList(startAt as List?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.dynamicList(startAfter as List?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.dynamicList(endAt as List?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.dynamicList(endBefore as List?), + ], endBeforeDocumentSnapshot: null, ); } @@ -4702,8 +5046,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['boolSet']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['boolSet']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4733,25 +5079,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.boolSet(startAt as Set?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.boolSet(startAfter as Set?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.boolSet(endAt as Set?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.boolSet(endBefore as Set?), + ], endBeforeDocumentSnapshot: null, ); } @@ -4775,8 +5133,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['enumValue']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['enumValue']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4806,25 +5166,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.enumValue(startAt as TestEnum), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.enumValue(startAfter as TestEnum), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.enumValue(endAt as TestEnum), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.enumValue(endBefore as TestEnum), + ], endBeforeDocumentSnapshot: null, ); } @@ -4849,8 +5221,9 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? startAfterDocument, }) { final query = $referenceWithoutCursor.orderBy( - _$NestedFieldMap['nullableEnumValue']!, - descending: descending); + _$NestedFieldMap['nullableEnumValue']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4880,25 +5253,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.nullableEnumValue(startAt as TestEnum?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.nullableEnumValue(startAfter as TestEnum?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.nullableEnumValue(endAt as TestEnum?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.nullableEnumValue(endBefore as TestEnum?), + ], endBeforeDocumentSnapshot: null, ); } @@ -4922,8 +5307,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['enumList']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['enumList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4953,25 +5340,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.enumList(startAt as List), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.enumList(startAfter as List), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.enumList(endAt as List), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.enumList(endBefore as List), + ], endBeforeDocumentSnapshot: null, ); } @@ -4995,8 +5394,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['nullableEnumList']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['nullableEnumList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -5026,25 +5427,39 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.nullableEnumList(startAt as List?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.nullableEnumList( + startAfter as List?, + ), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.nullableEnumList(endAt as List?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.nullableEnumList(endBefore as List?), + ], endBeforeDocumentSnapshot: null, ); } @@ -5075,9 +5490,7 @@ class NestedDocumentSnapshot extends FirestoreDocumentSnapshot { @override NestedDocumentReference get reference { - return NestedDocumentReference( - snapshot.reference, - ); + return NestedDocumentReference(snapshot.reference); } @override @@ -5086,11 +5499,7 @@ class NestedDocumentSnapshot extends FirestoreDocumentSnapshot { class NestedQuerySnapshot extends FirestoreQuerySnapshot { - NestedQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + NestedQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory NestedQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -5098,21 +5507,14 @@ class NestedQuerySnapshot final docs = snapshot.docs.map(NestedQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - NestedDocumentSnapshot._, - ); + return _decodeDocumentChange(change, NestedDocumentSnapshot._); }).toList(); - return NestedQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return NestedQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, NestedDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -5156,9 +5558,8 @@ abstract class EmptyModelCollectionReference implements EmptyModelQuery, FirestoreCollectionReference { - factory EmptyModelCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$EmptyModelCollectionReference; + factory EmptyModelCollectionReference([FirebaseFirestore? firestore]) = + _$EmptyModelCollectionReference; static EmptyModel fromFirestore( DocumentSnapshot> snapshot, @@ -5191,16 +5592,17 @@ class _$EmptyModelCollectionReference extends _$EmptyModelQuery firestore ??= FirebaseFirestore.instance; return _$EmptyModelCollectionReference._( - firestore.collection('config').withConverter( + firestore + .collection('config') + .withConverter( fromFirestore: EmptyModelCollectionReference.fromFirestore, toFirestore: EmptyModelCollectionReference.toFirestore, ), ); } - _$EmptyModelCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$EmptyModelCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -5214,9 +5616,7 @@ class _$EmptyModelCollectionReference extends _$EmptyModelQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return EmptyModelDocumentReference( - reference.doc(id), - ); + return EmptyModelDocumentReference(reference.doc(id)); } @override @@ -5403,17 +5803,17 @@ class _$EmptyModelQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(EmptyModelQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + EmptyModelQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -5470,7 +5870,8 @@ class _$EmptyModelQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -5502,7 +5903,8 @@ class _$EmptyModelQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -5523,8 +5925,10 @@ class _$EmptyModelQuery EmptyModelDocumentSnapshot? endBeforeDocument, EmptyModelDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -5596,8 +6000,10 @@ class _$EmptyModelQuery EmptyModelDocumentSnapshot? endBeforeDocument, EmptyModelDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -5676,22 +6082,17 @@ class EmptyModelDocumentSnapshot extends FirestoreDocumentSnapshot { @override EmptyModelDocumentReference get reference { - return EmptyModelDocumentReference( - snapshot.reference, - ); + return EmptyModelDocumentReference(snapshot.reference); } @override final EmptyModel? data; } -class EmptyModelQuerySnapshot extends FirestoreQuerySnapshot { - EmptyModelQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class EmptyModelQuerySnapshot + extends + FirestoreQuerySnapshot { + EmptyModelQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory EmptyModelQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -5699,21 +6100,14 @@ class EmptyModelQuerySnapshot extends FirestoreQuerySnapshot - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, EmptyModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -5758,9 +6152,8 @@ abstract class OptionalJsonCollectionReference implements OptionalJsonQuery, FirestoreCollectionReference { - factory OptionalJsonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$OptionalJsonCollectionReference; + factory OptionalJsonCollectionReference([FirebaseFirestore? firestore]) = + _$OptionalJsonCollectionReference; static OptionalJson fromFirestore( DocumentSnapshot> snapshot, @@ -5793,7 +6186,9 @@ class _$OptionalJsonCollectionReference extends _$OptionalJsonQuery firestore ??= FirebaseFirestore.instance; return _$OptionalJsonCollectionReference._( - firestore.collection('root').withConverter( + firestore + .collection('root') + .withConverter( fromFirestore: OptionalJsonCollectionReference.fromFirestore, toFirestore: OptionalJsonCollectionReference.toFirestore, ), @@ -5816,9 +6211,7 @@ class _$OptionalJsonCollectionReference extends _$OptionalJsonQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return OptionalJsonDocumentReference( - reference.doc(id), - ); + return OptionalJsonDocumentReference(reference.doc(id)); } @override @@ -5839,11 +6232,12 @@ class _$OptionalJsonCollectionReference extends _$OptionalJsonQuery int get hashCode => Object.hash(runtimeType, reference); } -abstract class OptionalJsonDocumentReference extends FirestoreDocumentReference< - OptionalJson, OptionalJsonDocumentSnapshot> { +abstract class OptionalJsonDocumentReference + extends + FirestoreDocumentReference { factory OptionalJsonDocumentReference( - DocumentReference reference) = - _$OptionalJsonDocumentReference; + DocumentReference reference, + ) = _$OptionalJsonDocumentReference; DocumentReference get reference; @@ -5907,10 +6301,7 @@ abstract class OptionalJsonDocumentReference extends FirestoreDocumentReference< /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - int value, - FieldValue valueFieldValue, - }); + Future update({int value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -5924,16 +6315,13 @@ abstract class OptionalJsonDocumentReference extends FirestoreDocumentReference< /// Updates fields in the current document using the batch API. /// /// The update will fail if applied to a document that does not exist. - void batchUpdate( - WriteBatch batch, { - int value, - FieldValue valueFieldValue, - }); + void batchUpdate(WriteBatch batch, {int value, FieldValue valueFieldValue}); } -class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< - OptionalJson, - OptionalJsonDocumentSnapshot> implements OptionalJsonDocumentReference { +class _$OptionalJsonDocumentReference + extends + FirestoreDocumentReference + implements OptionalJsonDocumentReference { _$OptionalJsonDocumentReference(this.reference); @override @@ -5989,7 +6377,11 @@ class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< _$OptionalJsonFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -6004,7 +6396,11 @@ class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< _$OptionalJsonFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -6017,8 +6413,10 @@ class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$OptionalJsonFieldMap['value']!: - _$OptionalJsonPerFieldToJson.value(value as int), + _$OptionalJsonFieldMap['value']!: _$OptionalJsonPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$OptionalJsonFieldMap['value']!: valueFieldValue, }; @@ -6037,8 +6435,10 @@ class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$OptionalJsonFieldMap['value']!: - _$OptionalJsonPerFieldToJson.value(value as int), + _$OptionalJsonFieldMap['value']!: _$OptionalJsonPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$OptionalJsonFieldMap['value']!: valueFieldValue, }; @@ -6057,8 +6457,10 @@ class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$OptionalJsonFieldMap['value']!: - _$OptionalJsonPerFieldToJson.value(value as int), + _$OptionalJsonFieldMap['value']!: _$OptionalJsonPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$OptionalJsonFieldMap['value']!: valueFieldValue, }; @@ -6208,17 +6610,17 @@ class _$OptionalJsonQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(OptionalJsonQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + OptionalJsonQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -6275,7 +6677,8 @@ class _$OptionalJsonQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -6307,7 +6710,8 @@ class _$OptionalJsonQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -6350,9 +6754,11 @@ class _$OptionalJsonQuery ? _$OptionalJsonPerFieldToJson.value(isGreaterThanOrEqualTo as int) : null, whereIn: whereIn?.map((e) => _$OptionalJsonPerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$OptionalJsonPerFieldToJson.value(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$OptionalJsonPerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -6373,8 +6779,10 @@ class _$OptionalJsonQuery OptionalJsonDocumentSnapshot? endBeforeDocument, OptionalJsonDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -6446,8 +6854,10 @@ class _$OptionalJsonQuery OptionalJsonDocumentSnapshot? endBeforeDocument, OptionalJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -6519,8 +6929,10 @@ class _$OptionalJsonQuery OptionalJsonDocumentSnapshot? endBeforeDocument, OptionalJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$OptionalJsonFieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$OptionalJsonFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -6550,25 +6962,37 @@ class _$OptionalJsonQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$OptionalJsonPerFieldToJson.value(startAt as int), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$OptionalJsonPerFieldToJson.value(startAfter as int), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$OptionalJsonPerFieldToJson.value(endAt as int), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$OptionalJsonPerFieldToJson.value(endBefore as int), + ], endBeforeDocumentSnapshot: null, ); } @@ -6600,45 +7024,37 @@ class OptionalJsonDocumentSnapshot @override OptionalJsonDocumentReference get reference { - return OptionalJsonDocumentReference( - snapshot.reference, - ); + return OptionalJsonDocumentReference(snapshot.reference); } @override final OptionalJson? data; } -class OptionalJsonQuerySnapshot extends FirestoreQuerySnapshot { - OptionalJsonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class OptionalJsonQuerySnapshot + extends + FirestoreQuerySnapshot< + OptionalJson, + OptionalJsonQueryDocumentSnapshot + > { + OptionalJsonQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory OptionalJsonQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, ) { - final docs = - snapshot.docs.map(OptionalJsonQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(OptionalJsonQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - OptionalJsonDocumentSnapshot._, - ); + return _decodeDocumentChange(change, OptionalJsonDocumentSnapshot._); }).toList(); - return OptionalJsonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return OptionalJsonQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, OptionalJsonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -6683,9 +7099,8 @@ abstract class MixedJsonCollectionReference implements MixedJsonQuery, FirestoreCollectionReference { - factory MixedJsonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$MixedJsonCollectionReference; + factory MixedJsonCollectionReference([FirebaseFirestore? firestore]) = + _$MixedJsonCollectionReference; static MixedJson fromFirestore( DocumentSnapshot> snapshot, @@ -6718,16 +7133,17 @@ class _$MixedJsonCollectionReference extends _$MixedJsonQuery firestore ??= FirebaseFirestore.instance; return _$MixedJsonCollectionReference._( - firestore.collection('root').withConverter( + firestore + .collection('root') + .withConverter( fromFirestore: MixedJsonCollectionReference.fromFirestore, toFirestore: MixedJsonCollectionReference.toFirestore, ), ); } - _$MixedJsonCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$MixedJsonCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -6741,9 +7157,7 @@ class _$MixedJsonCollectionReference extends _$MixedJsonQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return MixedJsonDocumentReference( - reference.doc(id), - ); + return MixedJsonDocumentReference(reference.doc(id)); } @override @@ -6829,10 +7243,7 @@ abstract class MixedJsonDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - int value, - FieldValue valueFieldValue, - }); + Future update({int value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -6846,11 +7257,7 @@ abstract class MixedJsonDocumentReference /// Updates fields in the current document using the batch API. /// /// The update will fail if applied to a document that does not exist. - void batchUpdate( - WriteBatch batch, { - int value, - FieldValue valueFieldValue, - }); + void batchUpdate(WriteBatch batch, {int value, FieldValue valueFieldValue}); } class _$MixedJsonDocumentReference @@ -6911,7 +7318,11 @@ class _$MixedJsonDocumentReference _$MixedJsonFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -6926,7 +7337,11 @@ class _$MixedJsonDocumentReference _$MixedJsonFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -6939,8 +7354,10 @@ class _$MixedJsonDocumentReference ); final json = { if (value != _sentinel) - _$MixedJsonFieldMap['value']!: - _$MixedJsonPerFieldToJson.value(value as int), + _$MixedJsonFieldMap['value']!: _$MixedJsonPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$MixedJsonFieldMap['value']!: valueFieldValue, }; @@ -6959,8 +7376,10 @@ class _$MixedJsonDocumentReference ); final json = { if (value != _sentinel) - _$MixedJsonFieldMap['value']!: - _$MixedJsonPerFieldToJson.value(value as int), + _$MixedJsonFieldMap['value']!: _$MixedJsonPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$MixedJsonFieldMap['value']!: valueFieldValue, }; @@ -6979,8 +7398,10 @@ class _$MixedJsonDocumentReference ); final json = { if (value != _sentinel) - _$MixedJsonFieldMap['value']!: - _$MixedJsonPerFieldToJson.value(value as int), + _$MixedJsonFieldMap['value']!: _$MixedJsonPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$MixedJsonFieldMap['value']!: valueFieldValue, }; @@ -7129,9 +7550,9 @@ class _$MixedJsonQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -7194,7 +7615,8 @@ class _$MixedJsonQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -7226,7 +7648,8 @@ class _$MixedJsonQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -7270,7 +7693,8 @@ class _$MixedJsonQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$MixedJsonPerFieldToJson.value(e)), whereNotIn: whereNotIn?.map((e) => _$MixedJsonPerFieldToJson.value(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -7291,8 +7715,10 @@ class _$MixedJsonQuery extends QueryReference MixedJsonDocumentSnapshot? endBeforeDocument, MixedJsonDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -7364,8 +7790,10 @@ class _$MixedJsonQuery extends QueryReference MixedJsonDocumentSnapshot? endBeforeDocument, MixedJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -7437,8 +7865,10 @@ class _$MixedJsonQuery extends QueryReference MixedJsonDocumentSnapshot? endBeforeDocument, MixedJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MixedJsonFieldMap['value']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MixedJsonFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -7468,25 +7898,37 @@ class _$MixedJsonQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MixedJsonPerFieldToJson.value(startAt as int), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MixedJsonPerFieldToJson.value(startAfter as int), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MixedJsonPerFieldToJson.value(endAt as int), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MixedJsonPerFieldToJson.value(endBefore as int), + ], endBeforeDocumentSnapshot: null, ); } @@ -7517,9 +7959,7 @@ class MixedJsonDocumentSnapshot extends FirestoreDocumentSnapshot { @override MixedJsonDocumentReference get reference { - return MixedJsonDocumentReference( - snapshot.reference, - ); + return MixedJsonDocumentReference(snapshot.reference); } @override @@ -7528,11 +7968,7 @@ class MixedJsonDocumentSnapshot extends FirestoreDocumentSnapshot { class MixedJsonQuerySnapshot extends FirestoreQuerySnapshot { - MixedJsonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + MixedJsonQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory MixedJsonQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -7540,21 +7976,14 @@ class MixedJsonQuerySnapshot final docs = snapshot.docs.map(MixedJsonQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - MixedJsonDocumentSnapshot._, - ); + return _decodeDocumentChange(change, MixedJsonDocumentSnapshot._); }).toList(); - return MixedJsonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return MixedJsonQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, MixedJsonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -7599,9 +8028,8 @@ abstract class RootCollectionReference implements RootQuery, FirestoreCollectionReference { - factory RootCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$RootCollectionReference; + factory RootCollectionReference([FirebaseFirestore? firestore]) = + _$RootCollectionReference; static Root fromFirestore( DocumentSnapshot> snapshot, @@ -7610,10 +8038,7 @@ abstract class RootCollectionReference return Root.fromJson(snapshot.data()!); } - static Map toFirestore( - Root value, - SetOptions? options, - ) { + static Map toFirestore(Root value, SetOptions? options) { return value.toJson(); } @@ -7634,16 +8059,17 @@ class _$RootCollectionReference extends _$RootQuery firestore ??= FirebaseFirestore.instance; return _$RootCollectionReference._( - firestore.collection('root').withConverter( + firestore + .collection('root') + .withConverter( fromFirestore: RootCollectionReference.fromFirestore, toFirestore: RootCollectionReference.toFirestore, ), ); } - _$RootCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$RootCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -7657,9 +8083,7 @@ class _$RootCollectionReference extends _$RootQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return RootDocumentReference( - reference.doc(id), - ); + return RootDocumentReference(reference.doc(id)); } @override @@ -7690,24 +8114,16 @@ abstract class RootDocumentReference return _$RootCollectionReference(reference.firestore); } - late final SubCollectionReference sub = _$SubCollectionReference( - reference, - ); + late final SubCollectionReference sub = _$SubCollectionReference(reference); late final AsCamelCaseCollectionReference asCamelCase = - _$AsCamelCaseCollectionReference( - reference, - ); + _$AsCamelCaseCollectionReference(reference); late final CustomSubNameCollectionReference thisIsACustomName = - _$CustomSubNameCollectionReference( - reference, - ); + _$CustomSubNameCollectionReference(reference); late final ThisIsACustomPrefixCollectionReference customClassPrefix = - _$ThisIsACustomPrefixCollectionReference( - reference, - ); + _$ThisIsACustomPrefixCollectionReference(reference); @override Stream snapshots(); @@ -7810,24 +8226,16 @@ class _$RootDocumentReference return _$RootCollectionReference(reference.firestore); } - late final SubCollectionReference sub = _$SubCollectionReference( - reference, - ); + late final SubCollectionReference sub = _$SubCollectionReference(reference); late final AsCamelCaseCollectionReference asCamelCase = - _$AsCamelCaseCollectionReference( - reference, - ); + _$AsCamelCaseCollectionReference(reference); late final CustomSubNameCollectionReference thisIsACustomName = - _$CustomSubNameCollectionReference( - reference, - ); + _$CustomSubNameCollectionReference(reference); late final ThisIsACustomPrefixCollectionReference customClassPrefix = - _$ThisIsACustomPrefixCollectionReference( - reference, - ); + _$ThisIsACustomPrefixCollectionReference(reference); @override Stream snapshots() { @@ -7854,6 +8262,7 @@ class _$RootDocumentReference ...model.toJson(), if (nonNullableFieldValue != null) _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullableFieldValue != null) _$RootFieldMap['nullable']!: nullableFieldValue, }; @@ -7876,11 +8285,16 @@ class _$RootDocumentReference ...model.toJson(), if (nonNullableFieldValue != null) _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullableFieldValue != null) _$RootFieldMap['nullable']!: nullableFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -7894,11 +8308,16 @@ class _$RootDocumentReference ...model.toJson(), if (nonNullableFieldValue != null) _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullableFieldValue != null) _$RootFieldMap['nullable']!: nullableFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -7917,13 +8336,18 @@ class _$RootDocumentReference ); final json = { if (nonNullable != _sentinel) - _$RootFieldMap['nonNullable']!: - _$RootPerFieldToJson.nonNullable(nonNullable as String), + _$RootFieldMap['nonNullable']!: _$RootPerFieldToJson.nonNullable( + nonNullable as String, + ), + if (nonNullableFieldValue != null) _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullable != _sentinel) - _$RootFieldMap['nullable']!: - _$RootPerFieldToJson.nullable(nullable as int?), + _$RootFieldMap['nullable']!: _$RootPerFieldToJson.nullable( + nullable as int?, + ), + if (nullableFieldValue != null) _$RootFieldMap['nullable']!: nullableFieldValue, }; @@ -7948,13 +8372,18 @@ class _$RootDocumentReference ); final json = { if (nonNullable != _sentinel) - _$RootFieldMap['nonNullable']!: - _$RootPerFieldToJson.nonNullable(nonNullable as String), + _$RootFieldMap['nonNullable']!: _$RootPerFieldToJson.nonNullable( + nonNullable as String, + ), + if (nonNullableFieldValue != null) _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullable != _sentinel) - _$RootFieldMap['nullable']!: - _$RootPerFieldToJson.nullable(nullable as int?), + _$RootFieldMap['nullable']!: _$RootPerFieldToJson.nullable( + nullable as int?, + ), + if (nullableFieldValue != null) _$RootFieldMap['nullable']!: nullableFieldValue, }; @@ -7979,13 +8408,18 @@ class _$RootDocumentReference ); final json = { if (nonNullable != _sentinel) - _$RootFieldMap['nonNullable']!: - _$RootPerFieldToJson.nonNullable(nonNullable as String), + _$RootFieldMap['nonNullable']!: _$RootPerFieldToJson.nonNullable( + nonNullable as String, + ), + if (nonNullableFieldValue != null) _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullable != _sentinel) - _$RootFieldMap['nullable']!: - _$RootPerFieldToJson.nullable(nullable as int?), + _$RootFieldMap['nullable']!: _$RootPerFieldToJson.nullable( + nullable as int?, + ), + if (nullableFieldValue != null) _$RootFieldMap['nullable']!: nullableFieldValue, }; @@ -8157,9 +8591,9 @@ class _$RootQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -8220,7 +8654,8 @@ class _$RootQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -8252,7 +8687,8 @@ class _$RootQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -8296,7 +8732,8 @@ class _$RootQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$RootPerFieldToJson.nonNullable(e)), whereNotIn: whereNotIn?.map((e) => _$RootPerFieldToJson.nonNullable(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -8340,7 +8777,8 @@ class _$RootQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$RootPerFieldToJson.nullable(e)), whereNotIn: whereNotIn?.map((e) => _$RootPerFieldToJson.nullable(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -8361,8 +8799,10 @@ class _$RootQuery extends QueryReference RootDocumentSnapshot? endBeforeDocument, RootDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -8434,8 +8874,10 @@ class _$RootQuery extends QueryReference RootDocumentSnapshot? endBeforeDocument, RootDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -8507,8 +8949,10 @@ class _$RootQuery extends QueryReference RootDocumentSnapshot? endBeforeDocument, RootDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$RootFieldMap['nonNullable']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$RootFieldMap['nonNullable']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -8538,25 +8982,37 @@ class _$RootQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$RootPerFieldToJson.nonNullable(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$RootPerFieldToJson.nonNullable(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$RootPerFieldToJson.nonNullable(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$RootPerFieldToJson.nonNullable(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -8580,8 +9036,10 @@ class _$RootQuery extends QueryReference RootDocumentSnapshot? endBeforeDocument, RootDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$RootFieldMap['nullable']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$RootFieldMap['nullable']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -8611,25 +9069,37 @@ class _$RootQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$RootPerFieldToJson.nullable(startAt as int?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$RootPerFieldToJson.nullable(startAfter as int?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$RootPerFieldToJson.nullable(endAt as int?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$RootPerFieldToJson.nullable(endBefore as int?), + ], endBeforeDocumentSnapshot: null, ); } @@ -8660,9 +9130,7 @@ class RootDocumentSnapshot extends FirestoreDocumentSnapshot { @override RootDocumentReference get reference { - return RootDocumentReference( - snapshot.reference, - ); + return RootDocumentReference(snapshot.reference); } @override @@ -8671,29 +9139,16 @@ class RootDocumentSnapshot extends FirestoreDocumentSnapshot { class RootQuerySnapshot extends FirestoreQuerySnapshot { - RootQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory RootQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { + RootQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory RootQuerySnapshot._fromQuerySnapshot(QuerySnapshot snapshot) { final docs = snapshot.docs.map(RootQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - RootDocumentSnapshot._, - ); + return _decodeDocumentChange(change, RootDocumentSnapshot._); }).toList(); - return RootQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return RootQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange _decodeDocumentChange( @@ -8738,9 +9193,8 @@ class RootQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot /// (using the methods inherited from Query). abstract class SubCollectionReference implements SubQuery, FirestoreCollectionReference { - factory SubCollectionReference( - DocumentReference parent, - ) = _$SubCollectionReference; + factory SubCollectionReference(DocumentReference parent) = + _$SubCollectionReference; static Sub fromFirestore( DocumentSnapshot> snapshot, @@ -8749,10 +9203,7 @@ abstract class SubCollectionReference return Sub.fromJson(snapshot.data()!); } - static Map toFirestore( - Sub value, - SetOptions? options, - ) { + static Map toFirestore(Sub value, SetOptions? options) { return value.toJson(); } @@ -8772,22 +9223,20 @@ abstract class SubCollectionReference class _$SubCollectionReference extends _$SubQuery implements SubCollectionReference { - factory _$SubCollectionReference( - DocumentReference parent, - ) { + factory _$SubCollectionReference(DocumentReference parent) { return _$SubCollectionReference._( RootDocumentReference(parent), - parent.collection('sub').withConverter( + parent + .collection('sub') + .withConverter( fromFirestore: SubCollectionReference.fromFirestore, toFirestore: SubCollectionReference.toFirestore, ), ); } - _$SubCollectionReference._( - this.parent, - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$SubCollectionReference._(this.parent, CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); @override final RootDocumentReference parent; @@ -8804,9 +9253,7 @@ class _$SubCollectionReference extends _$SubQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return SubDocumentReference( - reference.doc(id), - ); + return SubDocumentReference(reference.doc(id)); } @override @@ -8973,6 +9420,7 @@ class _$SubDocumentReference ...model.toJson(), if (nonNullableFieldValue != null) _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullableFieldValue != null) _$SubFieldMap['nullable']!: nullableFieldValue, }; @@ -8995,11 +9443,16 @@ class _$SubDocumentReference ...model.toJson(), if (nonNullableFieldValue != null) _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullableFieldValue != null) _$SubFieldMap['nullable']!: nullableFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -9013,11 +9466,16 @@ class _$SubDocumentReference ...model.toJson(), if (nonNullableFieldValue != null) _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullableFieldValue != null) _$SubFieldMap['nullable']!: nullableFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -9036,13 +9494,18 @@ class _$SubDocumentReference ); final json = { if (nonNullable != _sentinel) - _$SubFieldMap['nonNullable']!: - _$SubPerFieldToJson.nonNullable(nonNullable as String), + _$SubFieldMap['nonNullable']!: _$SubPerFieldToJson.nonNullable( + nonNullable as String, + ), + if (nonNullableFieldValue != null) _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullable != _sentinel) - _$SubFieldMap['nullable']!: - _$SubPerFieldToJson.nullable(nullable as int?), + _$SubFieldMap['nullable']!: _$SubPerFieldToJson.nullable( + nullable as int?, + ), + if (nullableFieldValue != null) _$SubFieldMap['nullable']!: nullableFieldValue, }; @@ -9067,13 +9530,18 @@ class _$SubDocumentReference ); final json = { if (nonNullable != _sentinel) - _$SubFieldMap['nonNullable']!: - _$SubPerFieldToJson.nonNullable(nonNullable as String), + _$SubFieldMap['nonNullable']!: _$SubPerFieldToJson.nonNullable( + nonNullable as String, + ), + if (nonNullableFieldValue != null) _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullable != _sentinel) - _$SubFieldMap['nullable']!: - _$SubPerFieldToJson.nullable(nullable as int?), + _$SubFieldMap['nullable']!: _$SubPerFieldToJson.nullable( + nullable as int?, + ), + if (nullableFieldValue != null) _$SubFieldMap['nullable']!: nullableFieldValue, }; @@ -9098,13 +9566,18 @@ class _$SubDocumentReference ); final json = { if (nonNullable != _sentinel) - _$SubFieldMap['nonNullable']!: - _$SubPerFieldToJson.nonNullable(nonNullable as String), + _$SubFieldMap['nonNullable']!: _$SubPerFieldToJson.nonNullable( + nonNullable as String, + ), + if (nonNullableFieldValue != null) _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullable != _sentinel) - _$SubFieldMap['nullable']!: - _$SubPerFieldToJson.nullable(nullable as int?), + _$SubFieldMap['nullable']!: _$SubPerFieldToJson.nullable( + nullable as int?, + ), + if (nullableFieldValue != null) _$SubFieldMap['nullable']!: nullableFieldValue, }; @@ -9276,9 +9749,9 @@ class _$SubQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -9339,7 +9812,8 @@ class _$SubQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -9371,7 +9845,8 @@ class _$SubQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -9415,7 +9890,8 @@ class _$SubQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$SubPerFieldToJson.nonNullable(e)), whereNotIn: whereNotIn?.map((e) => _$SubPerFieldToJson.nonNullable(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -9459,7 +9935,8 @@ class _$SubQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$SubPerFieldToJson.nullable(e)), whereNotIn: whereNotIn?.map((e) => _$SubPerFieldToJson.nullable(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -9480,8 +9957,10 @@ class _$SubQuery extends QueryReference SubDocumentSnapshot? endBeforeDocument, SubDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -9553,8 +10032,10 @@ class _$SubQuery extends QueryReference SubDocumentSnapshot? endBeforeDocument, SubDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -9626,8 +10107,10 @@ class _$SubQuery extends QueryReference SubDocumentSnapshot? endBeforeDocument, SubDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$SubFieldMap['nonNullable']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$SubFieldMap['nonNullable']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -9657,25 +10140,37 @@ class _$SubQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$SubPerFieldToJson.nonNullable(startAt as String), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$SubPerFieldToJson.nonNullable(startAfter as String), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$SubPerFieldToJson.nonNullable(endAt as String), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$SubPerFieldToJson.nonNullable(endBefore as String), + ], endBeforeDocumentSnapshot: null, ); } @@ -9699,8 +10194,10 @@ class _$SubQuery extends QueryReference SubDocumentSnapshot? endBeforeDocument, SubDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$SubFieldMap['nullable']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$SubFieldMap['nullable']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -9730,25 +10227,37 @@ class _$SubQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$SubPerFieldToJson.nullable(startAt as int?), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$SubPerFieldToJson.nullable(startAfter as int?), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$SubPerFieldToJson.nullable(endAt as int?), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$SubPerFieldToJson.nullable(endBefore as int?), + ], endBeforeDocumentSnapshot: null, ); } @@ -9779,9 +10288,7 @@ class SubDocumentSnapshot extends FirestoreDocumentSnapshot { @override SubDocumentReference get reference { - return SubDocumentReference( - snapshot.reference, - ); + return SubDocumentReference(snapshot.reference); } @override @@ -9790,29 +10297,16 @@ class SubDocumentSnapshot extends FirestoreDocumentSnapshot { class SubQuerySnapshot extends FirestoreQuerySnapshot { - SubQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory SubQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { + SubQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory SubQuerySnapshot._fromQuerySnapshot(QuerySnapshot snapshot) { final docs = snapshot.docs.map(SubQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - SubDocumentSnapshot._, - ); + return _decodeDocumentChange(change, SubDocumentSnapshot._); }).toList(); - return SubQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return SubQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange _decodeDocumentChange( @@ -9859,9 +10353,8 @@ abstract class AsCamelCaseCollectionReference implements AsCamelCaseQuery, FirestoreCollectionReference { - factory AsCamelCaseCollectionReference( - DocumentReference parent, - ) = _$AsCamelCaseCollectionReference; + factory AsCamelCaseCollectionReference(DocumentReference parent) = + _$AsCamelCaseCollectionReference; static AsCamelCase fromFirestore( DocumentSnapshot> snapshot, @@ -9893,12 +10386,12 @@ abstract class AsCamelCaseCollectionReference class _$AsCamelCaseCollectionReference extends _$AsCamelCaseQuery implements AsCamelCaseCollectionReference { - factory _$AsCamelCaseCollectionReference( - DocumentReference parent, - ) { + factory _$AsCamelCaseCollectionReference(DocumentReference parent) { return _$AsCamelCaseCollectionReference._( RootDocumentReference(parent), - parent.collection('as-camel-case').withConverter( + parent + .collection('as-camel-case') + .withConverter( fromFirestore: AsCamelCaseCollectionReference.fromFirestore, toFirestore: AsCamelCaseCollectionReference.toFirestore, ), @@ -9925,9 +10418,7 @@ class _$AsCamelCaseCollectionReference extends _$AsCamelCaseQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return AsCamelCaseDocumentReference( - reference.doc(id), - ); + return AsCamelCaseDocumentReference(reference.doc(id)); } @override @@ -9948,11 +10439,12 @@ class _$AsCamelCaseCollectionReference extends _$AsCamelCaseQuery int get hashCode => Object.hash(runtimeType, reference); } -abstract class AsCamelCaseDocumentReference extends FirestoreDocumentReference< - AsCamelCase, AsCamelCaseDocumentSnapshot> { +abstract class AsCamelCaseDocumentReference + extends + FirestoreDocumentReference { factory AsCamelCaseDocumentReference( - DocumentReference reference) = - _$AsCamelCaseDocumentReference; + DocumentReference reference, + ) = _$AsCamelCaseDocumentReference; DocumentReference get reference; @@ -10021,10 +10513,7 @@ abstract class AsCamelCaseDocumentReference extends FirestoreDocumentReference< /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); + Future update({num value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -10038,11 +10527,7 @@ abstract class AsCamelCaseDocumentReference extends FirestoreDocumentReference< /// Updates fields in the current document using the batch API. /// /// The update will fail if applied to a document that does not exist. - void batchUpdate( - WriteBatch batch, { - num value, - FieldValue valueFieldValue, - }); + void batchUpdate(WriteBatch batch, {num value, FieldValue valueFieldValue}); } class _$AsCamelCaseDocumentReference @@ -10108,7 +10593,11 @@ class _$AsCamelCaseDocumentReference _$AsCamelCaseFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -10123,7 +10612,11 @@ class _$AsCamelCaseDocumentReference _$AsCamelCaseFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -10136,8 +10629,10 @@ class _$AsCamelCaseDocumentReference ); final json = { if (value != _sentinel) - _$AsCamelCaseFieldMap['value']!: - _$AsCamelCasePerFieldToJson.value(value as num), + _$AsCamelCaseFieldMap['value']!: _$AsCamelCasePerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$AsCamelCaseFieldMap['value']!: valueFieldValue, }; @@ -10156,8 +10651,10 @@ class _$AsCamelCaseDocumentReference ); final json = { if (value != _sentinel) - _$AsCamelCaseFieldMap['value']!: - _$AsCamelCasePerFieldToJson.value(value as num), + _$AsCamelCaseFieldMap['value']!: _$AsCamelCasePerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$AsCamelCaseFieldMap['value']!: valueFieldValue, }; @@ -10176,8 +10673,10 @@ class _$AsCamelCaseDocumentReference ); final json = { if (value != _sentinel) - _$AsCamelCaseFieldMap['value']!: - _$AsCamelCasePerFieldToJson.value(value as num), + _$AsCamelCaseFieldMap['value']!: _$AsCamelCasePerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$AsCamelCaseFieldMap['value']!: valueFieldValue, }; @@ -10327,17 +10826,17 @@ class _$AsCamelCaseQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(AsCamelCaseQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + AsCamelCaseQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -10394,7 +10893,8 @@ class _$AsCamelCaseQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -10426,7 +10926,8 @@ class _$AsCamelCaseQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -10469,9 +10970,11 @@ class _$AsCamelCaseQuery ? _$AsCamelCasePerFieldToJson.value(isGreaterThanOrEqualTo as num) : null, whereIn: whereIn?.map((e) => _$AsCamelCasePerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$AsCamelCasePerFieldToJson.value(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$AsCamelCasePerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -10492,8 +10995,10 @@ class _$AsCamelCaseQuery AsCamelCaseDocumentSnapshot? endBeforeDocument, AsCamelCaseDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -10565,8 +11070,10 @@ class _$AsCamelCaseQuery AsCamelCaseDocumentSnapshot? endBeforeDocument, AsCamelCaseDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -10638,8 +11145,10 @@ class _$AsCamelCaseQuery AsCamelCaseDocumentSnapshot? endBeforeDocument, AsCamelCaseDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$AsCamelCaseFieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$AsCamelCaseFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -10669,25 +11178,37 @@ class _$AsCamelCaseQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$AsCamelCasePerFieldToJson.value(startAt as num), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$AsCamelCasePerFieldToJson.value(startAfter as num), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$AsCamelCasePerFieldToJson.value(endAt as num), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$AsCamelCasePerFieldToJson.value(endBefore as num), + ], endBeforeDocumentSnapshot: null, ); } @@ -10719,44 +11240,32 @@ class AsCamelCaseDocumentSnapshot @override AsCamelCaseDocumentReference get reference { - return AsCamelCaseDocumentReference( - snapshot.reference, - ); + return AsCamelCaseDocumentReference(snapshot.reference); } @override final AsCamelCase? data; } -class AsCamelCaseQuerySnapshot extends FirestoreQuerySnapshot { - AsCamelCaseQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class AsCamelCaseQuerySnapshot + extends + FirestoreQuerySnapshot { + AsCamelCaseQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory AsCamelCaseQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, ) { final docs = snapshot.docs.map(AsCamelCaseQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - AsCamelCaseDocumentSnapshot._, - ); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, AsCamelCaseDocumentSnapshot._); }).toList(); - return AsCamelCaseQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return AsCamelCaseQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, AsCamelCaseDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -10800,11 +11309,12 @@ class AsCamelCaseQueryDocumentSnapshot abstract class CustomSubNameCollectionReference implements CustomSubNameQuery, - FirestoreCollectionReference { - factory CustomSubNameCollectionReference( - DocumentReference parent, - ) = _$CustomSubNameCollectionReference; + FirestoreCollectionReference< + CustomSubName, + CustomSubNameQuerySnapshot + > { + factory CustomSubNameCollectionReference(DocumentReference parent) = + _$CustomSubNameCollectionReference; static CustomSubName fromFirestore( DocumentSnapshot> snapshot, @@ -10836,12 +11346,12 @@ abstract class CustomSubNameCollectionReference class _$CustomSubNameCollectionReference extends _$CustomSubNameQuery implements CustomSubNameCollectionReference { - factory _$CustomSubNameCollectionReference( - DocumentReference parent, - ) { + factory _$CustomSubNameCollectionReference(DocumentReference parent) { return _$CustomSubNameCollectionReference._( RootDocumentReference(parent), - parent.collection('custom-sub-name').withConverter( + parent + .collection('custom-sub-name') + .withConverter( fromFirestore: CustomSubNameCollectionReference.fromFirestore, toFirestore: CustomSubNameCollectionReference.toFirestore, ), @@ -10868,9 +11378,7 @@ class _$CustomSubNameCollectionReference extends _$CustomSubNameQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return CustomSubNameDocumentReference( - reference.doc(id), - ); + return CustomSubNameDocumentReference(reference.doc(id)); } @override @@ -10892,11 +11400,14 @@ class _$CustomSubNameCollectionReference extends _$CustomSubNameQuery } abstract class CustomSubNameDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + CustomSubName, + CustomSubNameDocumentSnapshot + > { factory CustomSubNameDocumentReference( - DocumentReference reference) = - _$CustomSubNameDocumentReference; + DocumentReference reference, + ) = _$CustomSubNameDocumentReference; DocumentReference get reference; @@ -10965,10 +11476,7 @@ abstract class CustomSubNameDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); + Future update({num value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -10982,16 +11490,13 @@ abstract class CustomSubNameDocumentReference /// Updates fields in the current document using the batch API. /// /// The update will fail if applied to a document that does not exist. - void batchUpdate( - WriteBatch batch, { - num value, - FieldValue valueFieldValue, - }); + void batchUpdate(WriteBatch batch, {num value, FieldValue valueFieldValue}); } -class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< - CustomSubName, - CustomSubNameDocumentSnapshot> implements CustomSubNameDocumentReference { +class _$CustomSubNameDocumentReference + extends + FirestoreDocumentReference + implements CustomSubNameDocumentReference { _$CustomSubNameDocumentReference(this.reference); @override @@ -11019,7 +11524,8 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(CustomSubNameDocumentSnapshot._); } @@ -11053,7 +11559,11 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< _$CustomSubNameFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -11068,7 +11578,11 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< _$CustomSubNameFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -11081,8 +11595,10 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$CustomSubNameFieldMap['value']!: - _$CustomSubNamePerFieldToJson.value(value as num), + _$CustomSubNameFieldMap['value']!: _$CustomSubNamePerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$CustomSubNameFieldMap['value']!: valueFieldValue, }; @@ -11101,8 +11617,10 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$CustomSubNameFieldMap['value']!: - _$CustomSubNamePerFieldToJson.value(value as num), + _$CustomSubNameFieldMap['value']!: _$CustomSubNamePerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$CustomSubNameFieldMap['value']!: valueFieldValue, }; @@ -11121,8 +11639,10 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$CustomSubNameFieldMap['value']!: - _$CustomSubNamePerFieldToJson.value(value as num), + _$CustomSubNameFieldMap['value']!: _$CustomSubNamePerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$CustomSubNameFieldMap['value']!: valueFieldValue, }; @@ -11272,17 +11792,17 @@ class _$CustomSubNameQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(CustomSubNameQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + CustomSubNameQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -11339,7 +11859,8 @@ class _$CustomSubNameQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -11371,7 +11892,8 @@ class _$CustomSubNameQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -11414,9 +11936,11 @@ class _$CustomSubNameQuery ? _$CustomSubNamePerFieldToJson.value(isGreaterThanOrEqualTo as num) : null, whereIn: whereIn?.map((e) => _$CustomSubNamePerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$CustomSubNamePerFieldToJson.value(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$CustomSubNamePerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -11437,8 +11961,10 @@ class _$CustomSubNameQuery CustomSubNameDocumentSnapshot? endBeforeDocument, CustomSubNameDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -11510,8 +12036,10 @@ class _$CustomSubNameQuery CustomSubNameDocumentSnapshot? endBeforeDocument, CustomSubNameDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -11583,8 +12111,10 @@ class _$CustomSubNameQuery CustomSubNameDocumentSnapshot? endBeforeDocument, CustomSubNameDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$CustomSubNameFieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$CustomSubNameFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -11614,25 +12144,37 @@ class _$CustomSubNameQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$CustomSubNamePerFieldToJson.value(startAt as num), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$CustomSubNamePerFieldToJson.value(startAfter as num), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$CustomSubNamePerFieldToJson.value(endAt as num), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$CustomSubNamePerFieldToJson.value(endBefore as num), + ], endBeforeDocumentSnapshot: null, ); } @@ -11664,45 +12206,37 @@ class CustomSubNameDocumentSnapshot @override CustomSubNameDocumentReference get reference { - return CustomSubNameDocumentReference( - snapshot.reference, - ); + return CustomSubNameDocumentReference(snapshot.reference); } @override final CustomSubName? data; } -class CustomSubNameQuerySnapshot extends FirestoreQuerySnapshot { - CustomSubNameQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class CustomSubNameQuerySnapshot + extends + FirestoreQuerySnapshot< + CustomSubName, + CustomSubNameQueryDocumentSnapshot + > { + CustomSubNameQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory CustomSubNameQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, ) { - final docs = - snapshot.docs.map(CustomSubNameQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(CustomSubNameQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - CustomSubNameDocumentSnapshot._, - ); + return _decodeDocumentChange(change, CustomSubNameDocumentSnapshot._); }).toList(); - return CustomSubNameQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return CustomSubNameQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, CustomSubNameDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -11746,8 +12280,10 @@ class CustomSubNameQueryDocumentSnapshot abstract class ThisIsACustomPrefixCollectionReference implements ThisIsACustomPrefixQuery, - FirestoreCollectionReference { + FirestoreCollectionReference< + CustomClassPrefix, + ThisIsACustomPrefixQuerySnapshot + > { factory ThisIsACustomPrefixCollectionReference( DocumentReference parent, ) = _$ThisIsACustomPrefixCollectionReference; @@ -11788,7 +12324,9 @@ class _$ThisIsACustomPrefixCollectionReference ) { return _$ThisIsACustomPrefixCollectionReference._( RootDocumentReference(parent), - parent.collection('custom-class-prefix').withConverter( + parent + .collection('custom-class-prefix') + .withConverter( fromFirestore: ThisIsACustomPrefixCollectionReference.fromFirestore, toFirestore: ThisIsACustomPrefixCollectionReference.toFirestore, ), @@ -11815,9 +12353,7 @@ class _$ThisIsACustomPrefixCollectionReference id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return ThisIsACustomPrefixDocumentReference( - reference.doc(id), - ); + return ThisIsACustomPrefixDocumentReference(reference.doc(id)); } @override @@ -11839,11 +12375,14 @@ class _$ThisIsACustomPrefixCollectionReference } abstract class ThisIsACustomPrefixDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + CustomClassPrefix, + ThisIsACustomPrefixDocumentSnapshot + > { factory ThisIsACustomPrefixDocumentReference( - DocumentReference reference) = - _$ThisIsACustomPrefixDocumentReference; + DocumentReference reference, + ) = _$ThisIsACustomPrefixDocumentReference; DocumentReference get reference; @@ -11912,10 +12451,7 @@ abstract class ThisIsACustomPrefixDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); + Future update({num value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -11929,15 +12465,15 @@ abstract class ThisIsACustomPrefixDocumentReference /// Updates fields in the current document using the batch API. /// /// The update will fail if applied to a document that does not exist. - void batchUpdate( - WriteBatch batch, { - num value, - FieldValue valueFieldValue, - }); + void batchUpdate(WriteBatch batch, {num value, FieldValue valueFieldValue}); } -class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< - CustomClassPrefix, ThisIsACustomPrefixDocumentSnapshot> +class _$ThisIsACustomPrefixDocumentReference + extends + FirestoreDocumentReference< + CustomClassPrefix, + ThisIsACustomPrefixDocumentSnapshot + > implements ThisIsACustomPrefixDocumentReference { _$ThisIsACustomPrefixDocumentReference(this.reference); @@ -11966,7 +12502,8 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction .get(reference) .then(ThisIsACustomPrefixDocumentSnapshot._); @@ -12002,7 +12539,11 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< _$CustomClassPrefixFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -12017,7 +12558,11 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< _$CustomClassPrefixFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -12030,8 +12575,9 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$CustomClassPrefixFieldMap['value']!: - _$CustomClassPrefixPerFieldToJson.value(value as num), + _$CustomClassPrefixFieldMap['value']!: _$CustomClassPrefixPerFieldToJson + .value(value as num), + if (valueFieldValue != null) _$CustomClassPrefixFieldMap['value']!: valueFieldValue, }; @@ -12050,8 +12596,9 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$CustomClassPrefixFieldMap['value']!: - _$CustomClassPrefixPerFieldToJson.value(value as num), + _$CustomClassPrefixFieldMap['value']!: _$CustomClassPrefixPerFieldToJson + .value(value as num), + if (valueFieldValue != null) _$CustomClassPrefixFieldMap['value']!: valueFieldValue, }; @@ -12070,8 +12617,9 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$CustomClassPrefixFieldMap['value']!: - _$CustomClassPrefixPerFieldToJson.value(value as num), + _$CustomClassPrefixFieldMap['value']!: _$CustomClassPrefixPerFieldToJson + .value(value as num), + if (valueFieldValue != null) _$CustomClassPrefixFieldMap['value']!: valueFieldValue, }; @@ -12222,18 +12770,19 @@ class _$ThisIsACustomPrefixQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override - Stream snapshots( - [SnapshotOptions? options]) { - return reference - .snapshots() - .map(ThisIsACustomPrefixQuerySnapshot._fromQuerySnapshot); + Stream snapshots([ + SnapshotOptions? options, + ]) { + return reference.snapshots().map( + ThisIsACustomPrefixQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -12290,7 +12839,8 @@ class _$ThisIsACustomPrefixQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -12322,7 +12872,8 @@ class _$ThisIsACustomPrefixQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -12356,21 +12907,26 @@ class _$ThisIsACustomPrefixQuery ? _$CustomClassPrefixPerFieldToJson.value(isLessThan as num) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$CustomClassPrefixPerFieldToJson - .value(isLessThanOrEqualTo as num) + ? _$CustomClassPrefixPerFieldToJson.value( + isLessThanOrEqualTo as num, + ) : null, isGreaterThan: isGreaterThan != null ? _$CustomClassPrefixPerFieldToJson.value(isGreaterThan as num) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$CustomClassPrefixPerFieldToJson - .value(isGreaterThanOrEqualTo as num) - : null, - whereIn: - whereIn?.map((e) => _$CustomClassPrefixPerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$CustomClassPrefixPerFieldToJson.value(e)), - isNull: isNull ?? + ? _$CustomClassPrefixPerFieldToJson.value( + isGreaterThanOrEqualTo as num, + ) + : null, + whereIn: whereIn?.map( + (e) => _$CustomClassPrefixPerFieldToJson.value(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$CustomClassPrefixPerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -12391,8 +12947,10 @@ class _$ThisIsACustomPrefixQuery ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -12464,8 +13022,10 @@ class _$ThisIsACustomPrefixQuery ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -12537,8 +13097,10 @@ class _$ThisIsACustomPrefixQuery ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$CustomClassPrefixFieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$CustomClassPrefixFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -12568,25 +13130,37 @@ class _$ThisIsACustomPrefixQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$CustomClassPrefixPerFieldToJson.value(startAt as num), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$CustomClassPrefixPerFieldToJson.value(startAfter as num), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$CustomClassPrefixPerFieldToJson.value(endAt as num), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$CustomClassPrefixPerFieldToJson.value(endBefore as num), + ], endBeforeDocumentSnapshot: null, ); } @@ -12618,28 +13192,27 @@ class ThisIsACustomPrefixDocumentSnapshot @override ThisIsACustomPrefixDocumentReference get reference { - return ThisIsACustomPrefixDocumentReference( - snapshot.reference, - ); + return ThisIsACustomPrefixDocumentReference(snapshot.reference); } @override final CustomClassPrefix? data; } -class ThisIsACustomPrefixQuerySnapshot extends FirestoreQuerySnapshot< - CustomClassPrefix, ThisIsACustomPrefixQueryDocumentSnapshot> { - ThisIsACustomPrefixQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class ThisIsACustomPrefixQuerySnapshot + extends + FirestoreQuerySnapshot< + CustomClassPrefix, + ThisIsACustomPrefixQueryDocumentSnapshot + > { + ThisIsACustomPrefixQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory ThisIsACustomPrefixQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, ) { - final docs = - snapshot.docs.map(ThisIsACustomPrefixQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(ThisIsACustomPrefixQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { return _decodeDocumentChange( @@ -12648,18 +13221,14 @@ class ThisIsACustomPrefixQuerySnapshot extends FirestoreQuerySnapshot< ); }).toList(); - return ThisIsACustomPrefixQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return ThisIsACustomPrefixQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, ThisIsACustomPrefixDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, + decodeDoc, ) { return FirestoreDocumentChange( type: docChange.type, @@ -12676,14 +13245,14 @@ class ThisIsACustomPrefixQuerySnapshot extends FirestoreQuerySnapshot< @override final List> - docChanges; + docChanges; } class ThisIsACustomPrefixQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements ThisIsACustomPrefixDocumentSnapshot { ThisIsACustomPrefixQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; @@ -12704,9 +13273,8 @@ abstract class ExplicitPathCollectionReference implements ExplicitPathQuery, FirestoreCollectionReference { - factory ExplicitPathCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$ExplicitPathCollectionReference; + factory ExplicitPathCollectionReference([FirebaseFirestore? firestore]) = + _$ExplicitPathCollectionReference; static ExplicitPath fromFirestore( DocumentSnapshot> snapshot, @@ -12739,7 +13307,9 @@ class _$ExplicitPathCollectionReference extends _$ExplicitPathQuery firestore ??= FirebaseFirestore.instance; return _$ExplicitPathCollectionReference._( - firestore.collection('root/doc/path').withConverter( + firestore + .collection('root/doc/path') + .withConverter( fromFirestore: ExplicitPathCollectionReference.fromFirestore, toFirestore: ExplicitPathCollectionReference.toFirestore, ), @@ -12762,9 +13332,7 @@ class _$ExplicitPathCollectionReference extends _$ExplicitPathQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return ExplicitPathDocumentReference( - reference.doc(id), - ); + return ExplicitPathDocumentReference(reference.doc(id)); } @override @@ -12785,11 +13353,12 @@ class _$ExplicitPathCollectionReference extends _$ExplicitPathQuery int get hashCode => Object.hash(runtimeType, reference); } -abstract class ExplicitPathDocumentReference extends FirestoreDocumentReference< - ExplicitPath, ExplicitPathDocumentSnapshot> { +abstract class ExplicitPathDocumentReference + extends + FirestoreDocumentReference { factory ExplicitPathDocumentReference( - DocumentReference reference) = - _$ExplicitPathDocumentReference; + DocumentReference reference, + ) = _$ExplicitPathDocumentReference; DocumentReference get reference; @@ -12799,9 +13368,7 @@ abstract class ExplicitPathDocumentReference extends FirestoreDocumentReference< } late final ExplicitSubPathCollectionReference sub = - _$ExplicitSubPathCollectionReference( - reference, - ); + _$ExplicitSubPathCollectionReference(reference); @override Stream snapshots(); @@ -12858,10 +13425,7 @@ abstract class ExplicitPathDocumentReference extends FirestoreDocumentReference< /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); + Future update({num value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -12875,16 +13439,13 @@ abstract class ExplicitPathDocumentReference extends FirestoreDocumentReference< /// Updates fields in the current document using the batch API. /// /// The update will fail if applied to a document that does not exist. - void batchUpdate( - WriteBatch batch, { - num value, - FieldValue valueFieldValue, - }); + void batchUpdate(WriteBatch batch, {num value, FieldValue valueFieldValue}); } -class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< - ExplicitPath, - ExplicitPathDocumentSnapshot> implements ExplicitPathDocumentReference { +class _$ExplicitPathDocumentReference + extends + FirestoreDocumentReference + implements ExplicitPathDocumentReference { _$ExplicitPathDocumentReference(this.reference); @override @@ -12896,9 +13457,7 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< } late final ExplicitSubPathCollectionReference sub = - _$ExplicitSubPathCollectionReference( - reference, - ); + _$ExplicitSubPathCollectionReference(reference); @override Stream snapshots() { @@ -12945,7 +13504,11 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< _$ExplicitPathFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -12960,7 +13523,11 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< _$ExplicitPathFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -12973,8 +13540,10 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$ExplicitPathFieldMap['value']!: - _$ExplicitPathPerFieldToJson.value(value as num), + _$ExplicitPathFieldMap['value']!: _$ExplicitPathPerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$ExplicitPathFieldMap['value']!: valueFieldValue, }; @@ -12993,8 +13562,10 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$ExplicitPathFieldMap['value']!: - _$ExplicitPathPerFieldToJson.value(value as num), + _$ExplicitPathFieldMap['value']!: _$ExplicitPathPerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$ExplicitPathFieldMap['value']!: valueFieldValue, }; @@ -13013,8 +13584,10 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$ExplicitPathFieldMap['value']!: - _$ExplicitPathPerFieldToJson.value(value as num), + _$ExplicitPathFieldMap['value']!: _$ExplicitPathPerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$ExplicitPathFieldMap['value']!: valueFieldValue, }; @@ -13164,17 +13737,17 @@ class _$ExplicitPathQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(ExplicitPathQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + ExplicitPathQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -13231,7 +13804,8 @@ class _$ExplicitPathQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -13263,7 +13837,8 @@ class _$ExplicitPathQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -13306,9 +13881,11 @@ class _$ExplicitPathQuery ? _$ExplicitPathPerFieldToJson.value(isGreaterThanOrEqualTo as num) : null, whereIn: whereIn?.map((e) => _$ExplicitPathPerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$ExplicitPathPerFieldToJson.value(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$ExplicitPathPerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -13329,8 +13906,10 @@ class _$ExplicitPathQuery ExplicitPathDocumentSnapshot? endBeforeDocument, ExplicitPathDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -13402,8 +13981,10 @@ class _$ExplicitPathQuery ExplicitPathDocumentSnapshot? endBeforeDocument, ExplicitPathDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -13475,8 +14056,10 @@ class _$ExplicitPathQuery ExplicitPathDocumentSnapshot? endBeforeDocument, ExplicitPathDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$ExplicitPathFieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$ExplicitPathFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -13506,25 +14089,37 @@ class _$ExplicitPathQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$ExplicitPathPerFieldToJson.value(startAt as num), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$ExplicitPathPerFieldToJson.value(startAfter as num), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$ExplicitPathPerFieldToJson.value(endAt as num), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$ExplicitPathPerFieldToJson.value(endBefore as num), + ], endBeforeDocumentSnapshot: null, ); } @@ -13556,45 +14151,37 @@ class ExplicitPathDocumentSnapshot @override ExplicitPathDocumentReference get reference { - return ExplicitPathDocumentReference( - snapshot.reference, - ); + return ExplicitPathDocumentReference(snapshot.reference); } @override final ExplicitPath? data; } -class ExplicitPathQuerySnapshot extends FirestoreQuerySnapshot { - ExplicitPathQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class ExplicitPathQuerySnapshot + extends + FirestoreQuerySnapshot< + ExplicitPath, + ExplicitPathQueryDocumentSnapshot + > { + ExplicitPathQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory ExplicitPathQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, ) { - final docs = - snapshot.docs.map(ExplicitPathQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(ExplicitPathQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - ExplicitPathDocumentSnapshot._, - ); + return _decodeDocumentChange(change, ExplicitPathDocumentSnapshot._); }).toList(); - return ExplicitPathQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return ExplicitPathQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, ExplicitPathDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -13638,8 +14225,10 @@ class ExplicitPathQueryDocumentSnapshot abstract class ExplicitSubPathCollectionReference implements ExplicitSubPathQuery, - FirestoreCollectionReference { + FirestoreCollectionReference< + ExplicitSubPath, + ExplicitSubPathQuerySnapshot + > { factory ExplicitSubPathCollectionReference( DocumentReference parent, ) = _$ExplicitSubPathCollectionReference; @@ -13679,7 +14268,9 @@ class _$ExplicitSubPathCollectionReference extends _$ExplicitSubPathQuery ) { return _$ExplicitSubPathCollectionReference._( ExplicitPathDocumentReference(parent), - parent.collection('sub').withConverter( + parent + .collection('sub') + .withConverter( fromFirestore: ExplicitSubPathCollectionReference.fromFirestore, toFirestore: ExplicitSubPathCollectionReference.toFirestore, ), @@ -13706,9 +14297,7 @@ class _$ExplicitSubPathCollectionReference extends _$ExplicitSubPathQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return ExplicitSubPathDocumentReference( - reference.doc(id), - ); + return ExplicitSubPathDocumentReference(reference.doc(id)); } @override @@ -13730,11 +14319,14 @@ class _$ExplicitSubPathCollectionReference extends _$ExplicitSubPathQuery } abstract class ExplicitSubPathDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + ExplicitSubPath, + ExplicitSubPathDocumentSnapshot + > { factory ExplicitSubPathDocumentReference( - DocumentReference reference) = - _$ExplicitSubPathDocumentReference; + DocumentReference reference, + ) = _$ExplicitSubPathDocumentReference; DocumentReference get reference; @@ -13803,10 +14395,7 @@ abstract class ExplicitSubPathDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); + Future update({num value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -13820,15 +14409,15 @@ abstract class ExplicitSubPathDocumentReference /// Updates fields in the current document using the batch API. /// /// The update will fail if applied to a document that does not exist. - void batchUpdate( - WriteBatch batch, { - num value, - FieldValue valueFieldValue, - }); + void batchUpdate(WriteBatch batch, {num value, FieldValue valueFieldValue}); } -class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< - ExplicitSubPath, ExplicitSubPathDocumentSnapshot> +class _$ExplicitSubPathDocumentReference + extends + FirestoreDocumentReference< + ExplicitSubPath, + ExplicitSubPathDocumentSnapshot + > implements ExplicitSubPathDocumentReference { _$ExplicitSubPathDocumentReference(this.reference); @@ -13857,7 +14446,8 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(ExplicitSubPathDocumentSnapshot._); } @@ -13891,7 +14481,11 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< _$ExplicitSubPathFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -13906,7 +14500,11 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< _$ExplicitSubPathFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -13919,8 +14517,9 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$ExplicitSubPathFieldMap['value']!: - _$ExplicitSubPathPerFieldToJson.value(value as num), + _$ExplicitSubPathFieldMap['value']!: _$ExplicitSubPathPerFieldToJson + .value(value as num), + if (valueFieldValue != null) _$ExplicitSubPathFieldMap['value']!: valueFieldValue, }; @@ -13939,8 +14538,9 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$ExplicitSubPathFieldMap['value']!: - _$ExplicitSubPathPerFieldToJson.value(value as num), + _$ExplicitSubPathFieldMap['value']!: _$ExplicitSubPathPerFieldToJson + .value(value as num), + if (valueFieldValue != null) _$ExplicitSubPathFieldMap['value']!: valueFieldValue, }; @@ -13959,8 +14559,9 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$ExplicitSubPathFieldMap['value']!: - _$ExplicitSubPathPerFieldToJson.value(value as num), + _$ExplicitSubPathFieldMap['value']!: _$ExplicitSubPathPerFieldToJson + .value(value as num), + if (valueFieldValue != null) _$ExplicitSubPathFieldMap['value']!: valueFieldValue, }; @@ -14110,17 +14711,17 @@ class _$ExplicitSubPathQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(ExplicitSubPathQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + ExplicitSubPathQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -14177,7 +14778,8 @@ class _$ExplicitSubPathQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -14209,7 +14811,8 @@ class _$ExplicitSubPathQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -14249,13 +14852,16 @@ class _$ExplicitSubPathQuery ? _$ExplicitSubPathPerFieldToJson.value(isGreaterThan as num) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$ExplicitSubPathPerFieldToJson - .value(isGreaterThanOrEqualTo as num) + ? _$ExplicitSubPathPerFieldToJson.value( + isGreaterThanOrEqualTo as num, + ) : null, whereIn: whereIn?.map((e) => _$ExplicitSubPathPerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$ExplicitSubPathPerFieldToJson.value(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$ExplicitSubPathPerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -14276,8 +14882,10 @@ class _$ExplicitSubPathQuery ExplicitSubPathDocumentSnapshot? endBeforeDocument, ExplicitSubPathDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -14349,8 +14957,10 @@ class _$ExplicitSubPathQuery ExplicitSubPathDocumentSnapshot? endBeforeDocument, ExplicitSubPathDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -14422,8 +15032,10 @@ class _$ExplicitSubPathQuery ExplicitSubPathDocumentSnapshot? endBeforeDocument, ExplicitSubPathDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$ExplicitSubPathFieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$ExplicitSubPathFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -14453,25 +15065,37 @@ class _$ExplicitSubPathQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$ExplicitSubPathPerFieldToJson.value(startAt as num), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$ExplicitSubPathPerFieldToJson.value(startAfter as num), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$ExplicitSubPathPerFieldToJson.value(endAt as num), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$ExplicitSubPathPerFieldToJson.value(endBefore as num), + ], endBeforeDocumentSnapshot: null, ); } @@ -14503,45 +15127,37 @@ class ExplicitSubPathDocumentSnapshot @override ExplicitSubPathDocumentReference get reference { - return ExplicitSubPathDocumentReference( - snapshot.reference, - ); + return ExplicitSubPathDocumentReference(snapshot.reference); } @override final ExplicitSubPath? data; } -class ExplicitSubPathQuerySnapshot extends FirestoreQuerySnapshot< - ExplicitSubPath, ExplicitSubPathQueryDocumentSnapshot> { - ExplicitSubPathQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class ExplicitSubPathQuerySnapshot + extends + FirestoreQuerySnapshot< + ExplicitSubPath, + ExplicitSubPathQueryDocumentSnapshot + > { + ExplicitSubPathQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory ExplicitSubPathQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, ) { - final docs = - snapshot.docs.map(ExplicitSubPathQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(ExplicitSubPathQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - ExplicitSubPathDocumentSnapshot._, - ); + return _decodeDocumentChange(change, ExplicitSubPathDocumentSnapshot._); }).toList(); - return ExplicitSubPathQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return ExplicitSubPathQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, ExplicitSubPathDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -14560,14 +15176,14 @@ class ExplicitSubPathQuerySnapshot extends FirestoreQuerySnapshot< @override final List> - docChanges; + docChanges; } class ExplicitSubPathQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements ExplicitSubPathDocumentSnapshot { ExplicitSubPathQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; @@ -14588,9 +15204,8 @@ abstract class SubClassCollectionReference implements SubClassQuery, FirestoreCollectionReference { - factory SubClassCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$SubClassCollectionReference; + factory SubClassCollectionReference([FirebaseFirestore? firestore]) = + _$SubClassCollectionReference; static SubClass fromFirestore( DocumentSnapshot> snapshot, @@ -14599,10 +15214,7 @@ abstract class SubClassCollectionReference return SubClass.fromJson(snapshot.data()!); } - static Map toFirestore( - SubClass value, - SetOptions? options, - ) { + static Map toFirestore(SubClass value, SetOptions? options) { return value.toJson(); } @@ -14623,16 +15235,17 @@ class _$SubClassCollectionReference extends _$SubClassQuery firestore ??= FirebaseFirestore.instance; return _$SubClassCollectionReference._( - firestore.collection('root').withConverter( + firestore + .collection('root') + .withConverter( fromFirestore: SubClassCollectionReference.fromFirestore, toFirestore: SubClassCollectionReference.toFirestore, ), ); } - _$SubClassCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$SubClassCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -14646,9 +15259,7 @@ class _$SubClassCollectionReference extends _$SubClassQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return SubClassDocumentReference( - reference.doc(id), - ); + return SubClassDocumentReference(reference.doc(id)); } @override @@ -14816,7 +15427,11 @@ class _$SubClassDocumentReference _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -14831,7 +15446,11 @@ class _$SubClassDocumentReference _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -14844,8 +15463,9 @@ class _$SubClassDocumentReference ); final json = { if (instanceGetter != _sentinel) - _$SubClassFieldMap['instanceGetter']!: - _$SubClassPerFieldToJson.instanceGetter(instanceGetter as int), + _$SubClassFieldMap['instanceGetter']!: _$SubClassPerFieldToJson + .instanceGetter(instanceGetter as int), + if (instanceGetterFieldValue != null) _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, }; @@ -14864,8 +15484,9 @@ class _$SubClassDocumentReference ); final json = { if (instanceGetter != _sentinel) - _$SubClassFieldMap['instanceGetter']!: - _$SubClassPerFieldToJson.instanceGetter(instanceGetter as int), + _$SubClassFieldMap['instanceGetter']!: _$SubClassPerFieldToJson + .instanceGetter(instanceGetter as int), + if (instanceGetterFieldValue != null) _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, }; @@ -14884,8 +15505,9 @@ class _$SubClassDocumentReference ); final json = { if (instanceGetter != _sentinel) - _$SubClassFieldMap['instanceGetter']!: - _$SubClassPerFieldToJson.instanceGetter(instanceGetter as int), + _$SubClassFieldMap['instanceGetter']!: _$SubClassPerFieldToJson + .instanceGetter(instanceGetter as int), + if (instanceGetterFieldValue != null) _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, }; @@ -15034,9 +15656,9 @@ class _$SubClassQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -15099,7 +15721,8 @@ class _$SubClassQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -15131,7 +15754,8 @@ class _$SubClassQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -15165,21 +15789,26 @@ class _$SubClassQuery extends QueryReference ? _$SubClassPerFieldToJson.instanceGetter(isLessThan as int) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$SubClassPerFieldToJson - .instanceGetter(isLessThanOrEqualTo as int) + ? _$SubClassPerFieldToJson.instanceGetter( + isLessThanOrEqualTo as int, + ) : null, isGreaterThan: isGreaterThan != null ? _$SubClassPerFieldToJson.instanceGetter(isGreaterThan as int) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$SubClassPerFieldToJson - .instanceGetter(isGreaterThanOrEqualTo as int) - : null, - whereIn: - whereIn?.map((e) => _$SubClassPerFieldToJson.instanceGetter(e)), - whereNotIn: - whereNotIn?.map((e) => _$SubClassPerFieldToJson.instanceGetter(e)), - isNull: isNull ?? + ? _$SubClassPerFieldToJson.instanceGetter( + isGreaterThanOrEqualTo as int, + ) + : null, + whereIn: whereIn?.map( + (e) => _$SubClassPerFieldToJson.instanceGetter(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$SubClassPerFieldToJson.instanceGetter(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -15200,8 +15829,10 @@ class _$SubClassQuery extends QueryReference SubClassDocumentSnapshot? endBeforeDocument, SubClassDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -15273,8 +15904,10 @@ class _$SubClassQuery extends QueryReference SubClassDocumentSnapshot? endBeforeDocument, SubClassDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -15346,8 +15979,10 @@ class _$SubClassQuery extends QueryReference SubClassDocumentSnapshot? endBeforeDocument, SubClassDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$SubClassFieldMap['instanceGetter']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$SubClassFieldMap['instanceGetter']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -15377,25 +16012,37 @@ class _$SubClassQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$SubClassPerFieldToJson.instanceGetter(startAt as int), + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$SubClassPerFieldToJson.instanceGetter(startAfter as int), + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$SubClassPerFieldToJson.instanceGetter(endAt as int), + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$SubClassPerFieldToJson.instanceGetter(endBefore as int), + ], endBeforeDocumentSnapshot: null, ); } @@ -15426,9 +16073,7 @@ class SubClassDocumentSnapshot extends FirestoreDocumentSnapshot { @override SubClassDocumentReference get reference { - return SubClassDocumentReference( - snapshot.reference, - ); + return SubClassDocumentReference(snapshot.reference); } @override @@ -15437,11 +16082,7 @@ class SubClassDocumentSnapshot extends FirestoreDocumentSnapshot { class SubClassQuerySnapshot extends FirestoreQuerySnapshot { - SubClassQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + SubClassQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory SubClassQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -15449,21 +16090,14 @@ class SubClassQuerySnapshot final docs = snapshot.docs.map(SubClassQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - SubClassDocumentSnapshot._, - ); + return _decodeDocumentChange(change, SubClassDocumentSnapshot._); }).toList(); - return SubClassQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return SubClassQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, SubClassDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -15517,9 +16151,7 @@ void _$assertMinValidation(MinValidation instance) { // ************************************************************************** IgnoredGetter _$IgnoredGetterFromJson(Map json) => - IgnoredGetter( - (json['value'] as num).toInt(), - ); + IgnoredGetter((json['value'] as num).toInt()); const _$IgnoredGetterFieldMap = { 'value': 'value', @@ -15535,18 +16167,12 @@ abstract class _$IgnoredGetterPerFieldToJson { } Map _$IgnoredGetterToJson(IgnoredGetter instance) => - { - 'value': instance.value, - 'count3': instance.count3, - }; + {'value': instance.value, 'count3': instance.count3}; -Model _$ModelFromJson(Map json) => Model( - json['value'] as String, - ); +Model _$ModelFromJson(Map json) => + Model(json['value'] as String); -const _$ModelFieldMap = { - 'value': 'value', -}; +const _$ModelFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$ModelPerFieldToJson { @@ -15555,38 +16181,39 @@ abstract class _$ModelPerFieldToJson { } Map _$ModelToJson(Model instance) => { - 'value': instance.value, - }; + 'value': instance.value, +}; Nested _$NestedFromJson(Map json) => Nested( - value: json['value'] == null - ? null - : Nested.fromJson(json['value'] as Map), - simple: (json['simple'] as num?)?.toInt(), - valueList: (json['valueList'] as List?) - ?.map((e) => Nested.fromJson(e as Map)) - .toList(), - boolList: - (json['boolList'] as List?)?.map((e) => e as bool).toList(), - stringList: (json['stringList'] as List?) - ?.map((e) => e as String) - .toList(), - numList: - (json['numList'] as List?)?.map((e) => e as num).toList(), - objectList: json['objectList'] as List?, - dynamicList: json['dynamicList'] as List?, - boolSet: - (json['boolSet'] as List?)?.map((e) => e as bool).toSet(), - enumValue: $enumDecode(_$TestEnumEnumMap, json['enumValue']), - nullableEnumValue: - $enumDecodeNullable(_$TestEnumEnumMap, json['nullableEnumValue']), - enumList: (json['enumList'] as List) - .map((e) => $enumDecode(_$TestEnumEnumMap, e)) - .toList(), - nullableEnumList: (json['nullableEnumList'] as List?) - ?.map((e) => $enumDecode(_$TestEnumEnumMap, e)) - .toList(), - ); + value: json['value'] == null + ? null + : Nested.fromJson(json['value'] as Map), + simple: (json['simple'] as num?)?.toInt(), + valueList: (json['valueList'] as List?) + ?.map((e) => Nested.fromJson(e as Map)) + .toList(), + boolList: (json['boolList'] as List?) + ?.map((e) => e as bool) + .toList(), + stringList: (json['stringList'] as List?) + ?.map((e) => e as String) + .toList(), + numList: (json['numList'] as List?)?.map((e) => e as num).toList(), + objectList: json['objectList'] as List?, + dynamicList: json['dynamicList'] as List?, + boolSet: (json['boolSet'] as List?)?.map((e) => e as bool).toSet(), + enumValue: $enumDecode(_$TestEnumEnumMap, json['enumValue']), + nullableEnumValue: $enumDecodeNullable( + _$TestEnumEnumMap, + json['nullableEnumValue'], + ), + enumList: (json['enumList'] as List) + .map((e) => $enumDecode(_$TestEnumEnumMap, e)) + .toList(), + nullableEnumList: (json['nullableEnumList'] as List?) + ?.map((e) => $enumDecode(_$TestEnumEnumMap, e)) + .toList(), +); const _$NestedFieldMap = { 'value': 'value', @@ -15638,21 +16265,22 @@ abstract class _$NestedPerFieldToJson { } Map _$NestedToJson(Nested instance) => { - 'value': instance.value, - 'simple': instance.simple, - 'valueList': instance.valueList, - 'boolList': instance.boolList, - 'stringList': instance.stringList, - 'numList': instance.numList, - 'objectList': instance.objectList, - 'dynamicList': instance.dynamicList, - 'boolSet': instance.boolSet?.toList(), - 'enumValue': _$TestEnumEnumMap[instance.enumValue]!, - 'nullableEnumValue': _$TestEnumEnumMap[instance.nullableEnumValue], - 'enumList': instance.enumList.map((e) => _$TestEnumEnumMap[e]!).toList(), - 'nullableEnumList': - instance.nullableEnumList?.map((e) => _$TestEnumEnumMap[e]!).toList(), - }; + 'value': instance.value, + 'simple': instance.simple, + 'valueList': instance.valueList, + 'boolList': instance.boolList, + 'stringList': instance.stringList, + 'numList': instance.numList, + 'objectList': instance.objectList, + 'dynamicList': instance.dynamicList, + 'boolSet': instance.boolSet?.toList(), + 'enumValue': _$TestEnumEnumMap[instance.enumValue]!, + 'nullableEnumValue': _$TestEnumEnumMap[instance.nullableEnumValue], + 'enumList': instance.enumList.map((e) => _$TestEnumEnumMap[e]!).toList(), + 'nullableEnumList': instance.nullableEnumList + ?.map((e) => _$TestEnumEnumMap[e]!) + .toList(), +}; const _$TestEnumEnumMap = { TestEnum.one: 'one', @@ -15700,10 +16328,8 @@ Map _$MinValidationToJson(MinValidation instance) => 'numNbr': instance.numNbr, }; -Root _$RootFromJson(Map json) => Root( - json['nonNullable'] as String, - (json['nullable'] as num?)?.toInt(), - ); +Root _$RootFromJson(Map json) => + Root(json['nonNullable'] as String, (json['nullable'] as num?)?.toInt()); const _$RootFieldMap = { 'nonNullable': 'nonNullable', @@ -15719,17 +16345,14 @@ abstract class _$RootPerFieldToJson { } Map _$RootToJson(Root instance) => { - 'nonNullable': instance.nonNullable, - 'nullable': instance.nullable, - }; + 'nonNullable': instance.nonNullable, + 'nullable': instance.nullable, +}; -OptionalJson _$OptionalJsonFromJson(Map json) => OptionalJson( - (json['value'] as num).toInt(), - ); +OptionalJson _$OptionalJsonFromJson(Map json) => + OptionalJson((json['value'] as num).toInt()); -const _$OptionalJsonFieldMap = { - 'value': 'value', -}; +const _$OptionalJsonFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$OptionalJsonPerFieldToJson { @@ -15738,17 +16361,12 @@ abstract class _$OptionalJsonPerFieldToJson { } Map _$OptionalJsonToJson(OptionalJson instance) => - { - 'value': instance.value, - }; + {'value': instance.value}; -MixedJson _$MixedJsonFromJson(Map json) => MixedJson( - (json['value'] as num).toInt(), - ); +MixedJson _$MixedJsonFromJson(Map json) => + MixedJson((json['value'] as num).toInt()); -const _$MixedJsonFieldMap = { - 'value': 'value', -}; +const _$MixedJsonFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$MixedJsonPerFieldToJson { @@ -15757,13 +16375,11 @@ abstract class _$MixedJsonPerFieldToJson { } Map _$MixedJsonToJson(MixedJson instance) => { - 'value': instance.value, - }; + 'value': instance.value, +}; -Sub _$SubFromJson(Map json) => Sub( - json['nonNullable'] as String, - (json['nullable'] as num?)?.toInt(), - ); +Sub _$SubFromJson(Map json) => + Sub(json['nonNullable'] as String, (json['nullable'] as num?)?.toInt()); const _$SubFieldMap = { 'nonNullable': 'nonNullable', @@ -15779,18 +16395,14 @@ abstract class _$SubPerFieldToJson { } Map _$SubToJson(Sub instance) => { - 'nonNullable': instance.nonNullable, - 'nullable': instance.nullable, - }; + 'nonNullable': instance.nonNullable, + 'nullable': instance.nullable, +}; CustomSubName _$CustomSubNameFromJson(Map json) => - CustomSubName( - json['value'] as num, - ); + CustomSubName(json['value'] as num); -const _$CustomSubNameFieldMap = { - 'value': 'value', -}; +const _$CustomSubNameFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$CustomSubNamePerFieldToJson { @@ -15799,17 +16411,12 @@ abstract class _$CustomSubNamePerFieldToJson { } Map _$CustomSubNameToJson(CustomSubName instance) => - { - 'value': instance.value, - }; + {'value': instance.value}; -AsCamelCase _$AsCamelCaseFromJson(Map json) => AsCamelCase( - json['value'] as num, - ); +AsCamelCase _$AsCamelCaseFromJson(Map json) => + AsCamelCase(json['value'] as num); -const _$AsCamelCaseFieldMap = { - 'value': 'value', -}; +const _$AsCamelCaseFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$AsCamelCasePerFieldToJson { @@ -15818,18 +16425,12 @@ abstract class _$AsCamelCasePerFieldToJson { } Map _$AsCamelCaseToJson(AsCamelCase instance) => - { - 'value': instance.value, - }; + {'value': instance.value}; CustomClassPrefix _$CustomClassPrefixFromJson(Map json) => - CustomClassPrefix( - json['value'] as num, - ); + CustomClassPrefix(json['value'] as num); -const _$CustomClassPrefixFieldMap = { - 'value': 'value', -}; +const _$CustomClassPrefixFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$CustomClassPrefixPerFieldToJson { @@ -15838,17 +16439,12 @@ abstract class _$CustomClassPrefixPerFieldToJson { } Map _$CustomClassPrefixToJson(CustomClassPrefix instance) => - { - 'value': instance.value, - }; + {'value': instance.value}; -ExplicitPath _$ExplicitPathFromJson(Map json) => ExplicitPath( - json['value'] as num, - ); +ExplicitPath _$ExplicitPathFromJson(Map json) => + ExplicitPath(json['value'] as num); -const _$ExplicitPathFieldMap = { - 'value': 'value', -}; +const _$ExplicitPathFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$ExplicitPathPerFieldToJson { @@ -15857,18 +16453,12 @@ abstract class _$ExplicitPathPerFieldToJson { } Map _$ExplicitPathToJson(ExplicitPath instance) => - { - 'value': instance.value, - }; + {'value': instance.value}; ExplicitSubPath _$ExplicitSubPathFromJson(Map json) => - ExplicitSubPath( - json['value'] as num, - ); + ExplicitSubPath(json['value'] as num); -const _$ExplicitSubPathFieldMap = { - 'value': 'value', -}; +const _$ExplicitSubPathFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$ExplicitSubPathPerFieldToJson { @@ -15877,17 +16467,12 @@ abstract class _$ExplicitSubPathPerFieldToJson { } Map _$ExplicitSubPathToJson(ExplicitSubPath instance) => - { - 'value': instance.value, - }; + {'value': instance.value}; -SubClass _$SubClassFromJson(Map json) => SubClass( - (json['instanceGetter'] as num).toInt(), - ); +SubClass _$SubClassFromJson(Map json) => + SubClass((json['instanceGetter'] as num).toInt()); -const _$SubClassFieldMap = { - 'instanceGetter': 'instanceGetter', -}; +const _$SubClassFieldMap = {'instanceGetter': 'instanceGetter'}; // ignore: unused_element abstract class _$SubClassPerFieldToJson { @@ -15896,5 +16481,5 @@ abstract class _$SubClassPerFieldToJson { } Map _$SubClassToJson(SubClass instance) => { - 'instanceGetter': instance.instanceGetter, - }; + 'instanceGetter': instance.instanceGetter, +}; diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/pubspec.yaml b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/pubspec.yaml index b3d3235..4db0592 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/pubspec.yaml +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/pubspec.yaml @@ -2,25 +2,27 @@ name: cloud_firestore_odm_generator_integration_test publish_to: none environment: - sdk: '>=2.18.0 <4.0.0' + sdk: ">=3.8.0 <4.0.0" dependencies: - cloud_firestore: ^5.0.0 - cloud_firestore_odm: ^1.0.0-dev.85 + cloud_firestore: ^6.0.0 + cloud_firestore_odm: ^1.2.0 flutter: sdk: flutter - freezed_annotation: ^2.2.0 - json_annotation: ^4.8.1 + freezed_annotation: ^3.1.0 + json_annotation: ^4.9.0 meta: ^1.12.0 dev_dependencies: - build_runner: ^2.4.2 + build_runner: ^2.7.0 cloud_firestore_odm_generator: path: ../ + firebase_core_platform_interface: ^6.0.0 flutter_test: sdk: flutter - freezed: ^2.3.2 - json_serializable: '>=6.6.1 <7.0.0' + freezed: ^3.2.0 + json_serializable: ^6.11.0 + test: ^1.25.15 dependency_overrides: cloud_firestore_odm: diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/collection_test.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/collection_test.dart index fb768c9..62a7da8 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/collection_test.dart +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/collection_test.dart @@ -2,13 +2,14 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'package:cloud_firestore_odm_generator_integration_test/freezed.dart'; import 'package:cloud_firestore_odm_generator_integration_test/simple.dart'; import 'package:flutter_test/flutter_test.dart'; import 'setup_firestore_mock.dart'; void main() { - setUpAll(setupCloudFirestoreMocks); + setUpAll(setupFirestoreMocks); test('can specify @Collection on the model itself', () { expect( @@ -35,8 +36,7 @@ void main() { }); group('doc', () { - test('asserts that the path does not point to a separate collection', - () async { + test('asserts that the path does not point to a separate collection', () async { rootRef.doc('42'); expect( @@ -49,4 +49,23 @@ void main() { ); }); }); + + /// test freezed mixed mode classes + group('freezed mixed mode classes', () { + test('test freezed simple classes', () { + const simpleFreezed = SimpleFreezed(a: 42); + expect(simpleFreezed.toJson(), {'a': 42}); + + final simpleFreezedFromJson = SimpleFreezed.fromJson({'a': 42}); + expect(simpleFreezedFromJson.a, 42); + }); + + test('test freezed factory classes', () { + final publicRedirected = PublicRedirected(value: 'test'); + expect(publicRedirected.toJson(), {'value': 'test'}); + + final publicRedirectedFromJson = PublicRedirected.fromJson({'value': 'test'}); + expect(publicRedirectedFromJson.value, 'test'); + }); + }); } diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/setup_firestore_mock.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/setup_firestore_mock.dart index b406e47..f0ffbd4 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/setup_firestore_mock.dart +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/setup_firestore_mock.dart @@ -2,13 +2,55 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart'; import 'package:flutter_test/flutter_test.dart'; -Future setupCloudFirestoreMocks() async { +void setupFirestoreMocks() { TestWidgetsFlutterBinding.ensureInitialized(); - setupFirebaseCoreMocks(); - await Firebase.initializeApp(); + // Mock Platform Interface + final platform = FirebasePlatform.instance; + if (platform is! MockFirebasePlatform) { + // Register Mock if not already registered + FirebasePlatform.instance = MockFirebasePlatform(); + } +} + +class MockFirebasePlatform extends FirebasePlatform { + @override + Future initializeApp({ + String? name, + FirebaseOptions? options, + }) async { + return MockFirebaseAppPlatform(); + } + + @override + FirebaseAppPlatform app([String name = defaultFirebaseAppName]) { + return MockFirebaseAppPlatform(); + } +} + +class MockFirebaseAppPlatform extends FirebaseAppPlatform { + MockFirebaseAppPlatform() + : super( + defaultFirebaseAppName, + const FirebaseOptions( + apiKey: 'mock-api-key', + appId: 'mock-app-id', + messagingSenderId: 'mock-sender-id', + projectId: 'mock-project-id', + ), + ); + + @override + String get name => defaultFirebaseAppName; + + @override + FirebaseOptions get options => const FirebaseOptions( + apiKey: 'mock-api-key', + appId: 'mock-app-id', + messagingSenderId: 'mock-sender-id', + projectId: 'mock-project-id', + ); } diff --git a/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart b/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart index 83ad3ec..8d77a65 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:analyzer/dart/constant/value.dart'; -import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/element2.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:cloud_firestore_odm/annotation.dart'; import 'package:collection/collection.dart'; @@ -15,9 +15,9 @@ import 'package:source_helper/source_helper.dart'; import 'collection_generator.dart'; import 'names.dart'; -const collectionChecker = TypeChecker.fromRuntime(Collection); -const jsonSerializableChecker = TypeChecker.fromRuntime(JsonSerializable); -const freezedChecker = TypeChecker.fromRuntime(Freezed); +const collectionChecker = TypeChecker.typeNamed(Collection); +const jsonSerializableChecker = TypeChecker.typeNamed(JsonSerializable); +const freezedChecker = TypeChecker.typeNamed(Freezed); class CollectionGraph { CollectionGraph._(this.roots, this.subCollections); @@ -88,12 +88,11 @@ class CollectionData with Names { required this.perFieldToJson, required this.idKey, required this.libraryElement, - }) : collectionName = - collectionName ?? ReCase(path.split('/').last).camelCase; + }) : collectionName = collectionName ?? ReCase(path.split('/').last).camelCase; factory CollectionData.fromAnnotation({ - required LibraryElement libraryElement, - required Element annotatedElement, + required LibraryElement2 libraryElement, + required Element2 annotatedElement, required DartObject annotation, required GlobalData globalData, }) { @@ -118,8 +117,8 @@ class CollectionData with Names { ); } - final collectionTargetElement = type.element; - if (collectionTargetElement is! ClassElement) { + final collectionTargetElement = type.element3; + if (collectionTargetElement is! ClassElement2) { throw InvalidGenerationSourceError( 'The annotation @Collection can only receive classes as generic argument. ', element: annotatedElement, @@ -127,44 +126,37 @@ class CollectionData with Names { } final hasFreezed = freezedChecker.hasAnnotationOf(collectionTargetElement); - final redirectedFreezedConstructors = - collectionTargetElement.constructors.where( - (element) { - return element.isFactory && - // It should be safe to read "redirectedConstructor" as the build.yaml - // asks to run the ODM after Freezed - element.redirectedConstructor != null; - }, - ).toList(); + final redirectedFreezedConstructors = collectionTargetElement.constructors2.where((element) { + return element.isFactory && + // It should be safe to read "redirectedConstructor" as the build.yaml + // asks to run the ODM after Freezed + element.redirectedConstructor2 != null; + }).toList(); - final hasJsonSerializable = - jsonSerializableChecker.hasAnnotationOf(collectionTargetElement); + final hasJsonSerializable = jsonSerializableChecker.hasAnnotationOf(collectionTargetElement); // Freezed classes are also JsonSerializable if (!hasJsonSerializable && !hasFreezed) { throw InvalidGenerationSourceError( - 'Used @Collection with the class ${collectionTargetElement.name}, but ' + 'Used @Collection with the class ${collectionTargetElement.name3}, but ' 'the class has no @JsonSerializable annotation.', ); } - final annotatedElementSource = annotatedElement.librarySource; + final annotatedElementSource = annotatedElement.library2; // TODO(rrousselGit) handle parts // Whether the model class and the reference variable are defined in the same file // This is important because json_serializable generates private code for // decoding a Model class. final modelAndReferenceInTheSameLibrary = - collectionTargetElement.librarySource == annotatedElementSource; + collectionTargetElement.library2 == annotatedElementSource; if (!modelAndReferenceInTheSameLibrary) { - throw InvalidGenerationSourceError( - ''' + throw InvalidGenerationSourceError(''' When using json_serializable, the `@Collection` annotation and the class that represents the content of the collection must be in the same file. - @Collection is from $annotatedElementSource -- `$collectionTargetElement` is from ${collectionTargetElement.librarySource} -''', - element: annotatedElement, - ); +- `$collectionTargetElement` is from ${collectionTargetElement.library2} +''', element: annotatedElement); } // TODO test error handling @@ -175,17 +167,17 @@ represents the content of the collection must be in the same file. ); } - final collectionTargetElementPublicType = - collectionTargetElement.name.public; - final fromJson = collectionTargetElement.constructors - .firstWhereOrNull((ctor) => ctor.name == 'fromJson'); + final collectionTargetElementPublicType = collectionTargetElement.name3?.public ?? ''; + final fromJson = collectionTargetElement.constructors2.firstWhereOrNull( + (ctor) => ctor.name3 == 'fromJson', + ); if (fromJson != null) { - if (fromJson.parameters.length != 1 || - !fromJson.parameters.first.isRequiredPositional || - !fromJson.parameters.first.type.isDartCoreMap) { + if (fromJson.formalParameters.length != 1 || + !fromJson.formalParameters.first.isRequiredPositional || + !fromJson.formalParameters.last.type.isDartCoreMap) { // TODO support deserializing generic objects throw InvalidGenerationSourceError( - '@Collection was used with the class ${collectionTargetElement.name} but ' + '@Collection was used with the class ${collectionTargetElement.name3} but ' 'its fromJson does not match `Function(Map json)`.', element: annotatedElement, ); @@ -194,19 +186,19 @@ represents the content of the collection must be in the same file. final toJson = collectionTargetElement // Looking into fromJson from superTypes too .allMethods - .firstWhereOrNull((method) => method.name == 'toJson'); - final redirectedFreezedClass = redirectedFreezedConstructors - .singleOrNull?.redirectedConstructor!.enclosingElement.name; + .firstWhereOrNull((method) => method.name3 == 'toJson'); + final redirectedFreezedClass = + redirectedFreezedConstructors.singleOrNull?.redirectedConstructor2!.enclosingElement2.name3; final generatedJsonTypePrefix = _generatedJsonTypePrefix( hasFreezed: hasFreezed, redirectedFreezedClass: redirectedFreezedClass, collectionTargetElementPublicType: collectionTargetElementPublicType, ); if (toJson != null) { - if (toJson.parameters.isNotEmpty || !toJson.returnType.isDartCoreMap) { + if (toJson.formalParameters.isNotEmpty || !toJson.returnType.isDartCoreMap) { // TODO support serializing generic objects throw InvalidGenerationSourceError( - '@Collection was used with the class ${collectionTargetElement.name} but ' + '@Collection was used with the class ${collectionTargetElement.name3} but ' 'its toJson does not match `Map Function()`.', element: annotatedElement, ); @@ -226,15 +218,11 @@ represents the content of the collection must be in the same file. if (toJson != null) return '$value.toJson()'; return '${generatedJsonTypePrefix}ToJson($value)'; }, - perFieldToJson: (field) => - '${generatedJsonTypePrefix}PerFieldToJson.$field', + perFieldToJson: (field) => '${generatedJsonTypePrefix}PerFieldToJson.$field', idKey: collectionTargetElement - .allFields( - hasFreezed: hasFreezed, - freezedConstructors: redirectedFreezedConstructors, - ) + .allFields(hasFreezed: hasFreezed, freezedConstructors: redirectedFreezedConstructors) .firstWhereOrNull((f) => f.hasId()) - ?.name, + ?.name3, queryableFields: [ QueryingField( 'fieldPath', @@ -277,34 +265,31 @@ represents the content of the collection must be in the same file. /// ```dart /// collection.orderByTitle(startAt: 'title'); /// ```''', - annotatedElement.library!.typeProvider.objectType, + annotatedElement.library2!.typeProvider.objectType, field: 'fieldPath', updatable: false, ), QueryingField( 'documentId', - annotatedElement.library!.typeProvider.stringType, + annotatedElement.library2!.typeProvider.stringType, whereDoc: '', // Inherited orderByDoc: '', // Inherited field: 'FieldPath.documentId', updatable: false, ), ...collectionTargetElement - .allFields( - hasFreezed: hasFreezed, - freezedConstructors: redirectedFreezedConstructors, - ) + .allFields(hasFreezed: hasFreezed, freezedConstructors: redirectedFreezedConstructors) .where((f) => f.isPublic) .where((f) => !f.hasId()) .where((f) => !f.isJsonIgnored()) .map( (f) => QueryingField( - f.name, + f.name3!, f.type, whereDoc: '', orderByDoc: '', updatable: true, - field: "${generatedJsonTypePrefix}FieldMap['${f.name}']!", + field: "${generatedJsonTypePrefix}FieldMap['${f.name3}']!", ), ) .toList(), @@ -313,8 +298,7 @@ represents the content of the collection must be in the same file. final classPrefix = data.classPrefix; - if (globalData.classPrefixesForLibrary[annotatedElementSource] - ?.contains(classPrefix) ?? + if (globalData.classPrefixesForLibrary[annotatedElementSource]?.contains(classPrefix) ?? false) { throw InvalidGenerationSourceError( 'Defined a collection with duplicate class prefix $classPrefix. ' @@ -323,13 +307,12 @@ represents the content of the collection must be in the same file. } globalData.classPrefixesForLibrary[annotatedElementSource] ??= []; - globalData.classPrefixesForLibrary[annotatedElementSource]! - .add(classPrefix); + globalData.classPrefixesForLibrary[annotatedElementSource]!.add(classPrefix); return data; } - static void _assertIsValidCollectionPath(String? path, Element element) { + static void _assertIsValidCollectionPath(String? path, Element2 element) { if (path == null) { throw InvalidGenerationSourceError( 'The annotation @Collection received "$path" as collection path, ' @@ -377,7 +360,9 @@ represents the content of the collection must be in the same file. required String collectionTargetElementPublicType, }) { if (hasFreezed) { - return '_\$\$${redirectedFreezedClass?.public}Impl'; + final className = redirectedFreezedClass?.public ?? collectionTargetElementPublicType; + // Only support freezed 3.x or higher + return '_\$$className'; } else { return '_\$$collectionTargetElementPublicType'; } @@ -392,10 +377,9 @@ represents the content of the collection must be in the same file. final String path; final String? idKey; final List queryableFields; - final LibraryElement libraryElement; + final LibraryElement2 libraryElement; - late final updatableFields = - queryableFields.where((element) => element.updatable).toList(); + late final updatableFields = queryableFields.where((element) => element.updatable).toList(); CollectionData? _parent; CollectionData? get parent => _parent; @@ -413,34 +397,45 @@ represents the content of the collection must be in the same file. } } -extension on ClassElement { - Iterable get allMethods sync* { - yield* methods; +extension on ClassElement2 { + Iterable get allMethods sync* { + yield* methods2; for (final supertype in allSupertypes) { if (supertype.isDartCoreObject) continue; - yield* supertype.methods; + yield* supertype.methods2; } } - Iterable allFields({ + Iterable allFields({ required bool hasFreezed, - required List freezedConstructors, + required List freezedConstructors, }) { if (hasFreezed) { - return freezedConstructors.single.parameters; + /// For Freezed 3.x, support mixed mode classes. There can be the classic freezed way with a factory, + /// or there can be simple regular classes with a normal constructor. + /// + /// We need to find the factory constructor, or the normal constructor if there is no factory. + final factoryConstructor = freezedConstructors.firstWhereOrNull( + (ctor) => ctor.isFactory && !ctor.name3!.startsWith('_') && ctor.name3 != 'fromJson', + ); + if (factoryConstructor == null) { + // No factory constructor, use the normal constructor + return fields2; + } + return factoryConstructor.formalParameters; } else { - final uniqueFields = {}; + final uniqueFields = {}; - final allFields = const [].followedBy(fields).followedBy( - allSupertypes - .where((e) => !e.isDartCoreObject) - .expand((e) => e.element.fields), + final allFields = const [] + .followedBy(fields2) + .followedBy( + allSupertypes.where((e) => !e.isDartCoreObject).expand((e) => e.element3.fields2), ); for (final field in allFields) { - if (field.getter != null && !field.getter!.isSynthetic) continue; + if (field.getter2 != null && !field.getter2!.isSynthetic) continue; if (field.isStatic) continue; - uniqueFields[field.name] ??= field; + uniqueFields[field.name3!] ??= field; } return uniqueFields.values; } @@ -458,10 +453,9 @@ const _coreSetChecker = TypeChecker.fromUrl('dart:core#Set'); extension DartTypeExtension on DartType { bool get isJsonDocumentReference { - return element?.librarySource?.uri.scheme == 'package' && - const {'cloud_firestore'} - .contains(element?.librarySource?.uri.pathSegments.first) && - element?.name == 'DocumentReference' && + return element3?.library2?.uri.scheme == 'package' && + const {'cloud_firestore'}.contains(element3?.library2?.uri.pathSegments.first) && + element3?.name3 == 'DocumentReference' && (this as InterfaceType).typeArguments.single.isDartCoreMap; } @@ -483,9 +477,9 @@ extension DartTypeExtension on DartType { } } -extension on Element { +extension on Element2 { bool isJsonIgnored() { - const checker = TypeChecker.fromRuntime(JsonKey); + const checker = TypeChecker.typeNamed(JsonKey); final jsonKeys = checker.annotationsOf(this); for (final jsonKey in jsonKeys) { @@ -494,7 +488,7 @@ extension on Element { // ignore is deprecated in favor of includeFromJson and includeToJson final jsonIncluded = (jsonKey.getField('includeFromJson')?.toBoolValue() ?? true) && - (jsonKey.getField('includeToJson')?.toBoolValue() ?? true); + (jsonKey.getField('includeToJson')?.toBoolValue() ?? true); if (ignore || !jsonIncluded) { return true; } @@ -504,7 +498,7 @@ extension on Element { } bool hasId() { - const checker = TypeChecker.fromRuntime(Id); + const checker = TypeChecker.typeNamed(Id); return checker.hasAnnotationOf(this); } } diff --git a/packages/cloud_firestore_odm_generator/lib/src/collection_generator.dart b/packages/cloud_firestore_odm_generator/lib/src/collection_generator.dart index b88cde5..dedbfe2 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/collection_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/collection_generator.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/element2.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:build/build.dart'; import 'package:cloud_firestore_odm/annotation.dart'; @@ -20,7 +20,7 @@ import 'templates/query_document_snapshot.dart'; import 'templates/query_reference.dart'; import 'templates/query_snapshot.dart'; -const namedQueryChecker = TypeChecker.fromRuntime(NamedQuery); +const namedQueryChecker = TypeChecker.typeNamed(NamedQuery); class QueryingField { QueryingField( @@ -66,21 +66,19 @@ class GlobalData { class CollectionGenerator extends ParserGenerator> { @override - GlobalData parseGlobalData(LibraryElement library) { + GlobalData parseGlobalData(LibraryElement2 library) { final globalData = GlobalData(); - for (final element in library.topLevelElements) { + for (final element in library.topLevelVariables) { for (final queryAnnotation in namedQueryChecker.annotationsOf(element)) { final queryData = NamedQueryData.fromAnnotation(queryAnnotation); - final hasCollectionWithMatchingModelType = - collectionChecker.annotationsOf(element).any( - (annotation) { - final collectionType = - CollectionData.modelTypeOfAnnotation(annotation); - return collectionType == queryData.type; - }, - ); + final hasCollectionWithMatchingModelType = collectionChecker.annotationsOf(element).any(( + annotation, + ) { + final collectionType = CollectionData.modelTypeOfAnnotation(annotation); + return collectionType == queryData.type; + }); if (!hasCollectionWithMatchingModelType) { throw InvalidGenerationSourceError( @@ -101,19 +99,17 @@ class CollectionGenerator Future parseElement( BuildStep buildStep, GlobalData globalData, - Element element, + Element2 element, ) async { final library = await buildStep.inputLibrary; - final collectionAnnotations = collectionChecker.annotationsOf(element).map( - (annotation) { - return CollectionData.fromAnnotation( - annotatedElement: element, - globalData: globalData, - libraryElement: library, - annotation: annotation, - ); - }, - ).toList(); + final collectionAnnotations = collectionChecker.annotationsOf(element).map((annotation) { + return CollectionData.fromAnnotation( + annotatedElement: element, + globalData: globalData, + libraryElement: library, + annotation: annotation, + ); + }).toList(); return CollectionGraph.parse(collectionAnnotations); } @@ -141,10 +137,7 @@ const _sentinel = _Sentinel(); } @override - Iterable generateForData( - GlobalData globalData, - CollectionGraph data, - ) sync* { + Iterable generateForData(GlobalData globalData, CollectionGraph data) sync* { for (final collection in data.allCollections) { yield CollectionReferenceTemplate(collection); yield DocumentReferenceTemplate(collection); diff --git a/packages/cloud_firestore_odm_generator/lib/src/parse_generator.dart b/packages/cloud_firestore_odm_generator/lib/src/parse_generator.dart index 9d04385..da313a2 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/parse_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/parse_generator.dart @@ -4,80 +4,49 @@ import 'dart:async'; -import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/element2.dart'; import 'package:build/build.dart'; import 'package:source_gen/source_gen.dart'; -abstract class ParserGenerator +import 'collection_generator.dart'; + +abstract class ParserGenerator extends GeneratorForAnnotation { @override - FutureOr generate( - // ignore: avoid_renaming_method_parameters - LibraryReader oldLibrary, - BuildStep buildStep, - ) async { - final library = await buildStep.resolver.libraryFor( - await buildStep.resolver.assetIdForElement(oldLibrary.element), - ); - + FutureOr generate(LibraryReader libraryReader, BuildStep buildStep) async { + final library = libraryReader.element; final generationBuffer = StringBuffer(); // A set used to remove duplicate generations. This is for scenarios where // two annotations within the library want to generate the same code final generatedCache = {}; final globalData = parseGlobalData(library); - - var hasGeneratedGlobalCode = false; - - for (final element - in library.topLevelElements.where(typeChecker.hasAnnotationOf)) { - if (!hasGeneratedGlobalCode) { - hasGeneratedGlobalCode = true; - for (final generated - in generateForAll(globalData).map((e) => e.toString())) { - assert(generated.length == generated.trim().length); - if (generatedCache.add(generated)) { - generationBuffer.writeln(generated); - } - } - } - - final data = await parseElement(buildStep, globalData, element); - if (data == null) continue; - - for (final generated - in generateForData(globalData, data).map((e) => e.toString())) { - assert(generated.length == generated.trim().length); - - if (generatedCache.add(generated)) { - generationBuffer.writeln(generated); - } + for (final generated in generateForAll(globalData).map((e) => e.toString())) { + assert(generated.length == generated.trim().length); + if (generatedCache.add(generated)) { + generationBuffer.writeln(generated); } } - return generationBuffer.toString(); + return '$generationBuffer\n\n${await super.generate(libraryReader, buildStep)}'; } Iterable generateForAll(GlobalData globalData) sync* {} - GlobalData parseGlobalData(LibraryElement library); + GlobalData parseGlobalData(LibraryElement2 library); - FutureOr parseElement( - BuildStep buildStep, - GlobalData globalData, - Element element, - ); + FutureOr parseElement(BuildStep buildStep, GlobalData globalData, Element2 element); Iterable generateForData(GlobalData globalData, Data data); @override Stream generateForAnnotatedElement( - Element element, + Element2 element, ConstantReader annotation, BuildStep buildStep, ) async* { // implemented for source_gen_test – otherwise unused - final globalData = parseGlobalData(element.library!); + final globalData = parseGlobalData(element.library2!); final data = parseElement(buildStep, globalData, element); if (data == null) return; diff --git a/packages/cloud_firestore_odm_generator/lib/src/templates/document_reference.dart b/packages/cloud_firestore_odm_generator/lib/src/templates/document_reference.dart index 7f7104a..2975b4b 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/templates/document_reference.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/templates/document_reference.dart @@ -193,12 +193,28 @@ void batchSet( fieldValuesNullable: true, ); final fieldValuesJson = _json(data, includeFields: false); + final json = ''' { ...${data.toJson('model')}, $fieldValuesJson }'''; + final idKey = data.idKey; + + String toFirestoreBody; + if (idKey != null) { + toFirestoreBody = "value..remove('$idKey')"; + } else { + toFirestoreBody = 'value'; + } + + final castedReferenceStr = ''' +reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => $toFirestoreBody, +)'''; + return ''' Future set( $type model, { @@ -207,10 +223,7 @@ Future set( }) async { final json = $json; - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); + final castedReference = $castedReferenceStr; return castedReference.set(json, options); } @@ -222,7 +235,8 @@ void transactionSet( }) { final json = $json; - transaction.set(reference, json, options); + final castedReference = $castedReferenceStr; + transaction.set(castedReference, json, options); } void batchSet( @@ -233,7 +247,8 @@ void batchSet( }) { final json = $json; - batch.set(reference, json, options); + final castedReference = $castedReferenceStr; + batch.set(castedReference, json, options); } '''; } diff --git a/packages/cloud_firestore_odm_generator/lib/src/templates/query_reference.dart b/packages/cloud_firestore_odm_generator/lib/src/templates/query_reference.dart index 72d9517..d6bcffa 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/templates/query_reference.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/templates/query_reference.dart @@ -149,6 +149,12 @@ class ${data.queryReferenceImplName} if (field.name == 'fieldPath') '${field.type} fieldPath,', ].join(); + String withToJson(String arg) { + return field.name == 'documentId' || field.name == 'fieldPath' + ? arg + : '${data.perFieldToJson(field.name)}($arg as ${field.type})'; + } + buffer.writeln( ''' @override @@ -193,25 +199,25 @@ class ${data.queryReferenceImplName} if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [...queryCursor.startAt, ${withToJson('startAt')}], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [...queryCursor.startAfter, ${withToJson('startAfter')}], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [...queryCursor.endAt, ${withToJson('endAt')}], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [...queryCursor.endBefore, ${withToJson('endBefore')}], endBeforeDocumentSnapshot: null, ); } @@ -238,14 +244,12 @@ class ${data.queryReferenceImplName} (match) => match.group(0)!.toUpperCase(), ); - final nullableType = - field.type.nullabilitySuffix == NullabilitySuffix.question - ? '${field.type}' - : '${field.type}?'; + final nullableType = field.type.nullabilitySuffix == NullabilitySuffix.question + ? '${field.type}' + : '${field.type}?'; final nullableWhereType = _WherePrototype.plain(nullableType); - final sentinelObjectWhereType = - _WherePrototype.plain('Object?', '_sentinel'); + final sentinelObjectWhereType = _WherePrototype.plain('Object?', '_sentinel'); final objectWhereType = _WherePrototype.plain('Object?'); final perFieldToJson = data.perFieldToJson(field.name); @@ -322,10 +326,7 @@ class ${data.queryReferenceImplName} map: (name) { final itemType = field.name == 'fieldPath' ? field.type.toString() - : (field.type as InterfaceType) - .typeArguments - .first - .toString(); + : (field.type as InterfaceType).typeArguments.first.toString(); final cast = itemType != 'Object?' ? ' as $itemType' : ''; var transform = '$name != null ? ($perFieldToJson('; @@ -339,8 +340,7 @@ class ${data.queryReferenceImplName} ), 'arrayContainsAny': _WhereMapper( prototype: nullableWhereType, - map: (name) => - '$name != null ? $perFieldToJson($name) as Iterable? : null', + map: (name) => '$name != null ? $perFieldToJson($name) as Iterable? : null', ), } else if (!field.type.isSupportedIterable) ...{ 'whereIn': inMapper, @@ -354,8 +354,7 @@ class ${data.queryReferenceImplName} ), }; - final prototype = - operators.entries.map((e) => e.value.prototype.call(e.key)).join(); + final prototype = operators.entries.map((e) => e.value.prototype.call(e.key)).join(); final parameters = operators.entries.map((entry) { final key = entry.key; diff --git a/packages/cloud_firestore_odm_generator/lib/src/validator_generator.dart b/packages/cloud_firestore_odm_generator/lib/src/validator_generator.dart index 44e7a89..9477ed2 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/validator_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/validator_generator.dart @@ -4,7 +4,7 @@ import 'dart:async'; -import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/element2.dart'; import 'package:build/build.dart'; import 'package:source_gen/source_gen.dart'; @@ -14,18 +14,18 @@ class ValidatorGenerator extends Generator { final buffer = StringBuffer(); for (final classElement in library.classes) { - final validations = classElement.fields.expand((field) sync* { - final validators = field.metadata.where(isValidatorAnnotation); + final validations = classElement.fields2.expand((field) sync* { + final validators = field.metadata2.annotations.where(isValidatorAnnotation); for (final validator in validators) { - yield "${validator.toSource().replaceFirst('@', 'const ')}.validate(instance.${field.name}, '${field.name}');"; + yield "${validator.toSource().replaceFirst('@', 'const ')}.validate(instance.${field.name3}, '${field.name3}');"; } }).toList(); if (validations.isNotEmpty) { buffer ..write( - 'void _\$assert${classElement.name}(${classElement.name} instance) {', + 'void _\$assert${classElement.name3}(${classElement.name3} instance) {', ) ..writeAll(validations) ..write('}'); @@ -37,12 +37,12 @@ class ValidatorGenerator extends Generator { } bool isValidatorAnnotation(ElementAnnotation annotation) { - final element = annotation.element; - if (element == null || element is! ConstructorElement) return false; + final element = annotation.element2; + if (element == null || element is! ConstructorElement2) return false; - return element.enclosingElement.allSupertypes.any((superType) { - return superType.element.name == 'Validator' && - superType.element.librarySource.uri.toString() == + return element.enclosingElement2.allSupertypes.any((superType) { + return superType.element3.name3 == 'Validator' && + superType.element3.library2.uri.toString() == 'package:cloud_firestore_odm/src/validator.dart'; }); } diff --git a/packages/cloud_firestore_odm_generator/pubspec.yaml b/packages/cloud_firestore_odm_generator/pubspec.yaml index fdab7d5..7ff59fe 100644 --- a/packages/cloud_firestore_odm_generator/pubspec.yaml +++ b/packages/cloud_firestore_odm_generator/pubspec.yaml @@ -2,29 +2,32 @@ name: cloud_firestore_odm_generator description: A code generator for cloud_firestore_odm. homepage: https://firebase.flutter.dev/docs/firestore/odm repository: https://github.com/firebaseextended/firestoreodm-flutter -version: 1.0.0-dev.90 +version: 1.3.0 environment: - sdk: ">=2.18.0 <4.0.0" + sdk: ">=3.8.0 <4.0.0" dependencies: - analyzer: ">=5.12.0 <7.0.0" - build: ^2.0.1 - build_config: ^1.0.0 - cloud_firestore_odm: ^1.0.0-dev.87 - collection: ^1.15.0 - freezed_annotation: ">=1.0.0 <3.0.0" + analyzer: ">=6.0.0 <9.0.0" + build: ^3.0.2 + build_config: ^1.2.0 + cloud_firestore_odm: ^1.2.0 + # For testing locally + # cloud_firestore_odm: + # path: ../cloud_firestore_odm + collection: ^1.18.0 + freezed_annotation: ^3.0.0 # Can be removed once this is fixed https://github.com/dart-lang/graphs/issues/86 - graphs: ^2.0.0 - json_annotation: ^4.8.1 - meta: ^1.8.0 - recase: ^4.0.0 - source_gen: ^1.3.2 - source_helper: ^1.3.4 + graphs: ^2.3.1 + json_annotation: ^4.9.0 + meta: ^1.12.0 + recase: ^4.1.0 + source_gen: ^3.1.0 + source_helper: ^1.3.7 dev_dependencies: - build_runner: ^2.4.2 - expect_error: ^1.0.5 - json_serializable: ">=6.3.0 <7.0.0" - matcher: ^0.12.10 - test: ^1.16.8 + build_runner: ^2.7.0 + expect_error: ^1.0.10 + json_serializable: ^6.11.0 + matcher: ^0.12.17 + test: ^1.25.15 diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh new file mode 100755 index 0000000..49d5368 --- /dev/null +++ b/scripts/run-tests.sh @@ -0,0 +1,22 @@ +cd packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test +dart run build_runner build -d +flutter test +cd .. +dart test +cd ../cloud_firestore_odm +flutter test +cd example +dart run build_runner build -d +firebase emulators:start --only firestore & +FIREBASE_EMULATOR_PID=$! + +chromedriver --port=4444 & +CHROMEDRIVER_PID=$! + +flutter drive --driver=test_driver/integration_test.dart --target=integration_test/cloud_firestore_odm_e2e_test.dart -d chrome +kill $CHROMEDRIVER_PID +kill $FIREBASE_EMULATOR_PID + + + +