Reputation: 562
I have the following code:
DocumentReference ref = db.collection(Paths.playersPath).doc(uid);
var data = {
'uid': uid,
'name': name,
'email': email,
'joinDate': FieldValue.serverTimestamp(),
};
ref.set(data, SetOptions(merge: true));
final DocumentSnapshot currentDoc = await ref.get();
user = Player.fromFirestore(currentDoc);
When I save this in firebase, it is having an error:
type 'Null' is not a subtype of type 'Timestamp'
When I show this via print, it shows the following value:
FieldValue(Instance of 'MethodChannelFieldValue')
Please help on what is the issue. Thanks!
Upvotes: 0
Views: 825
Reputation: 1
For Kotlin, Timestamp(Date()) in place of FieldValue.serverTimestamp() worked. To use Timestamp(Date()), you must import com.google.firebase.Timestamp. Not sure if things are different for Flutter.
Upvotes: 0