dart – Flutter app error – 类型’Timestamp’不是’DateTime’类型的子类型

dart – Flutter app error – 类型’Timestamp’不是’DateTime’类型的子类型,第1张

概述我正在获取数据云firestore&试图通过使用以下代码在我的应用程序中显示. new Text(timeago.format(document.data['tripDoc']['docCreatedOn'])), 我正在使用timeago dart包来格式化.但是,在更新到最新的云firestore插件后,我收到此错误 – Another exception was thrown: type ' 我正在获取数据云firestore&试图通过使用以下代码在我的应用程序中显示.

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

我正在使用timeago dart包来格式化.但是,在更新到最新的云firestore插件后,我收到此错误 –

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

无法理解如何将此’TimeStamp’对象解析为’DateTime’.因为timeago插件需要DateTime对象格式的数据.

解决方法 .toDate()为我工作.现在修改后的代码是 –

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

希望,它会帮助某人.

总结

以上是内存溢出为你收集整理的dart – Flutter app error – 类型’Timestamp’不是’DateTime’类型的子类型全部内容,希望文章能够帮你解决dart – Flutter app error – 类型’Timestamp’不是’DateTime’类型的子类型所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1000487.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-21
下一篇2022-05-21

发表评论

登录后才能评论

评论列表(0条)

    保存