Straight to the issue. I am new to Firebase Firestore.
I have model:
@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,
);
The data that is to be saved in Firebase Firestore is Timestamp for createDate
and updatedDate
.
But the problem is that I cannot convert the data from Firebase to local. The save method converts the dateCreate
to Timestamp fine.
static DateTime _fromJson(int int) =>
DateTime.fromMillisecondsSinceEpoch(int);
static int _toJson(DateTime time) => time.millisecondsSinceEpoch;
Any solution please.