Flutter客户端使用Firebase Timestamp字段报错:无getSeconds方法
解决Firebase Timestamp的getSeconds()报错问题
错误原因
新版Firebase的Timestamp类已经移除了getSeconds()方法,改为直接通过属性访问时间戳数据。
修复后的代码
final docRef = firestore.collection(usersCollection).doc(currentUID).collection(friendsCollection).doc('a6b5Ob3TqOYPHOqssype'); final returnData = await docRef.get(); final time = returnData.get('timestamp'); print('##MyApp## database test returnData: ' + time.seconds.toString());
额外说明
- 如果需要获取包含毫秒级的完整时间戳,可使用
time.millisecondsSinceEpoch - 如果需要微秒级时间戳,使用
time.microsecondsSinceEpoch
内容的提问来源于stack exchange,提问作者whatwhatwhat
相关产品推荐
相关产品推荐

