【发布时间】:2020-12-15 00:34:16
【问题描述】:
向firestore添加数据时,数据库将DateTime对象转换为TimeStamp
我的代码:
class JobApplication {
DateTime time;
JobApplication({this.time});
JobApplication.fromMap(Map<String, dynamic> map)
: time = map['time'] as DateTime;
Map<String, dynamic> toMap() {
return {
'time': this.time,};
}
获取时显示以下错误
Expected a value of type 'DateTime', but got one of type 'Timestamp'
The relevant error-causing widget was:
StreamBuilder<QuerySnapshot> file:///home/koha/Projects/sirajulhuda_app/lib/screens/job_appli_screen.dart:56:24
When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 212:49 throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 60:3 castError
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 442:10 cast
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart 411:9 as
packages/sirajulhuda_app/models/job_application.dart 72:26 fromMap
【问题讨论】:
标签: flutter google-cloud-firestore