Flutter应用程序错误-类型'Timestamp'不是类型'DateTime'的子类型 [英] Flutter app error - type 'Timestamp' is not a subtype of type 'DateTime'

查看:133
本文介绍了Flutter应用程序错误-类型'Timestamp'不是类型'DateTime'的子类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在获取数据云存储区&尝试使用以下代码在我的应用中显示。

I'm fetching data cloud firestore & trying to show in my app by using the following piece of code.

new Text(timeago.format(document.data['tripDoc']['docCreatedOn'])),

我正在使用 timeago dart软件包以对其进行格式化。但是,在更新到最新的Cloud Firestore插件后,出现了此错误-

I'm using timeago dart package to format that. But, after making updating to latest cloud firestore plugin I'm getting this error -

Another exception was thrown: type 'Timestamp' is not a subtype of type 'DateTime'

无法理解如何解析此 TimeStamp '指向'DateTime'。因为 timeago 插件需要DateTime对象格式的数据。

Can't able to understand how to parse this 'TimeStamp' object to 'DateTime'. Because timeago plugin need data in DateTime object format.

推荐答案

.toDate()为我工作。现在修改后的代码是-

.toDate() worked for me. Now the modified code is -

new Text(timeago.format(document.data['tripDoc']['docCreatedOn'].toDate()))

希望,它会帮助某人。

这篇关于Flutter应用程序错误-类型'Timestamp'不是类型'DateTime'的子类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆