Google cloud firestore 扑动火场日期

Google cloud firestore 扑动火场日期,google-cloud-firestore,flutter,Google Cloud Firestore,Flutter,我知道这是重复,但由于我一直无法找到正确的方法,所以请不要将此标记为重复。 我想在Flatter中将日期类型正确设置为Firestore。我尝试了DateTime.now(),但当我检索它时,错误显示 不支持的值:FIRTimestamp:seconds=1533950401纳秒=81000000>类型为FIRTimestamp 应用程序将崩溃。我还尝试了millissecondssinceepoch,microsecondsSinceEpoch,toUtc,但Firestore将它们识别为数字

我知道这是重复,但由于我一直无法找到正确的方法,所以请不要将此标记为重复。 我想在Flatter中将日期类型正确设置为
Firestore
。我尝试了
DateTime.now()
,但当我检索它时,错误显示

不支持的值:FIRTimestamp:seconds=1533950401纳秒=81000000>类型为FIRTimestamp

应用程序将崩溃。我还尝试了
millissecondssinceepoch
microsecondsSinceEpoch
toUtc
,但Firestore将它们识别为数字而不是时间戳。我使用了
intl
包,格式为
yyyy-MM-dd-hh:MM
,但它被识别为字符串。
有人知道如何正确设置时间戳吗?

Firestore数据库只有时间戳字段记录。以下操作正常工作并正确保存了时间戳

Firestore.instance.collection('COLLECTION_NAME').add({
   'weight': someDoubleValue,
   'when': DateTime.now(),
});
这是我的

firebase_core: ^0.2.5
cloud_firestore: ^0.8.2
使用

FieldValue.serverTimestamp()