小编Bar*_*pps的帖子

Flutter 问题:“Timestamp”类型不是“DateTime”类型的子类型

我正在为我和我的团队正在开发的应用程序寻求帮助。我们面临以下问题数周:

flutter type 'Timestamp' is not a subtype of type 'DateTime'
Run Code Online (Sandbox Code Playgroud)

我们想从Cloud Firestore获取这些用户数据:

  • 出生 [日期时间]
  • 性别 [字符串]
  • 许可证 [日期时间]
  • 名称 [字符串]
  • 大小 [字符串]
  • 重量 [字符串]

Cloud Firestore 中仅将出生执照作为 [Timestamp] 存储,因此我们将这些数据解析为 [DateTime]。

这是我们获取用户数据的代码:

import 'package:cloud_firestore/cloud_firestore.dart';

class User{
  final String _name;
  final String _gender; // 'homme' or 'femme' or 'autre'
  final DateTime _birth;
  final DateTime _license;
  final double _weight;
  final int _size;
  DocumentReference ref;

  User(this._birth,this._gender,this._license,this._name,this._size,this._weight,this.ref);

  User.fromMap(Map<String, dynamic> map, {this.ref})
      : assert(map['name'] != null && map['gender'] != …
Run Code Online (Sandbox Code Playgroud)

timestamp dart firebase flutter google-cloud-firestore

2
推荐指数
1
解决办法
3962
查看次数