You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Batches and transactions fail with error like: TypeError: Instance of '(TestSerializable, SetOptions?) => Map<String, Object?>': type '(TestSerializable, SetOptions?) => Map<String, Object?>' is not a subtype of type '(Object, SetOptions?) => Map<String, Object?>'
Steps to Reproduce the Problem
import'package:cloud_firestore/cloud_firestore.dart';
import'package:cloud_firestore_odm/cloud_firestore_odm.dart';
import'package:json_annotation/json_annotation.dart';
part'test.g.dart';
/// A custom JsonSerializable annotation that supports decoding objects such/// as Timestamps and DateTimes./// This variable can be reused between different modelsconst firestoreSerializable =JsonSerializable(
converters: firestoreJsonConverters,
// The following values could alternatively be set inside your `build.yaml`
explicitToJson:true,
createFieldMap:true,
createPerFieldToJson:true,
);
@firestoreSerializableclassTestSerializable {
TestSerializable({
requiredthis.origin,
});
finalString origin;
}
@Collection<TestSerializable>('test')
final testCollectionReference =TestSerializableCollectionReference();
test() async {
testCollectionReference.doc("id1").set(TestSerializable(origin:'regular'));
final batch =FirebaseFirestore.instance.batch();
testCollectionReference.doc("id2").batchSet(batch, TestSerializable(origin:'batch'));
await batch.commit();
FirebaseFirestore.instance.runTransaction((transaction) async {
testCollectionReference.doc("id3").transactionSet(transaction, TestSerializable(origin:'transaction'));
});
}
Execute test() in a flutter project where Firestore is configured
Verify in Firestore console that test collection contains doc id1, but no id2 or id3.
Expected Behavior
Batches and transactions should work
Actual Behavior
Batches and transactions fail with error like:
TypeError: Instance of '(TestSerializable, SetOptions?) => Map<String, Object?>': type '(TestSerializable, SetOptions?) => Map<String, Object?>' is not a subtype of type '(Object, SetOptions?) => Map<String, Object?>'
Steps to Reproduce the Problem
Specifications
The text was updated successfully, but these errors were encountered: