Hey @ditman , While doing pagination on flutter web, cloud firestore gives error error-Invalid argument (dartObject): Could not convert: Instance of 'Timestamp'
try {
Firestore fireStore = Firestore.instance;
final QuerySnapshot docs = await fireStore
.collectionGroup("vote")
.where("uid", isEqualTo: uid)
.orderBy(fieldVal, descending: true)
.startAfterDocument(doc)
.limit(2)
.getDocuments();
} catch (e) {
print("error-" + e.toString());
return null;
}
Hi @kushvatsa
can you please provide your flutter doctor -v ,
your flutter run --verbose
and your pubspec.yaml
or if possible a reproducible minimal code sample.
Thank you
@kushvatsa can you also describe a little bit the data structures you're using? Is the Timestamp failing in the startAfterDocument line, or elsewhere?
Is this because your doc contains a Timestamp type?
final String fieldVal = 'created_time';
DocumentSnapshot doc;
initData() async {
try {
final docs = await Firestore.instance
.collectionGroup("vote")
.where("uid", isEqualTo: uid)
.orderBy(fieldVal, descending: true)
.limit(2)
.getDocuments();
doc = docs.documents.first;
} catch (e) {
print("error-" + e.toString());
return null;
}
}
nextData() async {
try {
Firestore fireStore = Firestore.instance;
await fireStore
.collectionGroup("vote")
.where("uid", isEqualTo: uid)
.orderBy(fieldVal, descending: true)
.startAfterDocument(doc)
.limit(2)
.getDocuments();
} catch (e) {
print("error-" + e.toString());
return null;
}
}
@ditman , yes. TimeStamp failing in the startAfterDocument and also in the endBeforeDocument.
@iapicca , check the above comment. Thanks!
Hi @kushvatsa
could you please provide these info
thank you
@iapicca no need, this comes from a past issue where I asked @kushvatsa to start a new one. This issue can be reproduced by the tests of the _web plugin. I'll get on this ASAP. Thanks!
Thank for the clarification @ditman
The current tests can reproduce this issue:
00:07 +7: Firestore pagination [E]
Invalid argument (dartObject): Could not convert: Instance of 'Timestamp'
package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 196:49 throw_
package:firebase/src/utils.dart 119:3 jsify
package:dart-sdk/lib/internal/iterable.dart 417:29 elementAt
package:dart-sdk/lib/internal/iterable.dart 221:19 toList
package:firebase/src/firestore.dart 552:22
[_wrapPaginatingFunctionCall]
package:firebase/src/firestore.dart 523:11 startAt
package:cloud_firestore_web/src/query_web.dart 180:17 startAtDocument
package:cloud_firestore/src/query.dart 130:17 startAtDocument
package:firestore_example/main.dart 193:48 <fn>
The error happens here.
Investigating.
Tagged and published cloud_firestore_web 0.1.1+2 with a fix for this issue. Please update your dependencies and let me know how it goes!
It works @ditman , Thank you very much. 馃憤
Awesome, thanks for your patience!
Most helpful comment
Tagged and published cloud_firestore_web 0.1.1+2 with a fix for this issue. Please update your dependencies and let me know how it goes!