Skip to content

Commit

Permalink
😑 force dynamic instead of TimeStamp
Browse files Browse the repository at this point in the history
  • Loading branch information
yelkamel committed Oct 23, 2023
1 parent b6308f5 commit d656cc9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/jsonconverter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ class FirestoreDateTimeWithNullConverter
}

class FirestoreListDateTimeConverter
extends JsonConverter<List<DateTime>, List<Timestamp>> {
extends JsonConverter<List<DateTime>, List<dynamic>> {
const FirestoreListDateTimeConverter();
@override
List<DateTime> fromJson(List<dynamic> json) => json.map((e) {
if (e is Timestamp)
return DateTime.fromMillisecondsSinceEpoch(e.millisecondsSinceEpoch);
return DateTime.fromMillisecondsSinceEpoch(0);
return DateTime.fromMillisecondsSinceEpoch(e.millisecondsSinceEpoch);
}).toList();

@override
List<Timestamp> toJson(List<DateTime> object) => object
List<dynamic> toJson(List<DateTime> object) => object
.map(
(e) => Timestamp.fromMillisecondsSinceEpoch(e.millisecondsSinceEpoch))
.toList();
Expand Down

0 comments on commit d656cc9

Please sign in to comment.