【发布时间】:2021-05-30 02:02:49
【问题描述】:
直奔主题。我是 Firebase Firestore 的新手。
我有模特:
@JsonSerializable()
class CategoryEntity extends Equatable {
final String id;
final String name;
@JsonKey(fromJson: _fromJson, toJson: _toJson)
final DateTime createdDate;
@JsonKey(fromJson: _fromJson, toJson: _toJson)
final DateTime updatedDate;
final String description;
const CategoryEntity(
this.id,
this.name,
this.createdDate,
this.updatedDate,
this.description,
);
要保存在 Firebase Firestore 中的数据是 createDate 和 updatedDate 的时间戳。
但问题是我无法将数据从 Firebase 转换为本地数据。 save 方法将dateCreate 转换为时间戳罚款。
static DateTime _fromJson(int int) =>
DateTime.fromMillisecondsSinceEpoch(int);
static int _toJson(DateTime time) => time.millisecondsSinceEpoch;
请提供任何解决方案。
【问题讨论】:
标签: firebase flutter google-cloud-firestore