I'm using flutter and firestore and what I want to do is adding an object as a child inside a list, each time I hit a submit button. Inside that object, I want to have a createdAt field, where the timestamp information should be stored. For that, i'm trying to use FieldValue.serverTimestamp(), but i'm getting the following error.
Uncaught (in promise) Error: [cloud_firestore/unknown] Invalid argument (dartObject): Could not convert: Instance of '_FieldValueServerTimestamp'
The code is as below:
reference.update({
'parentData': FieldValue.arrayUnion([
{
'data': myData,
'createdAt': FieldValue.serverTimestamp()
}
]),
});
I'm also importing the library:
import 'package:cloud_firestore/cloud_firestore.dart';