I am trying to convert a firebase timestamp that has been returned from a could function to a date object in flutter.
I already tried those solutions but they didn't work: Converting timestamp
Here is the code I am using:
await firebaseFunctions
.httpsCallable('functionName')
.call({"data": data}).then((value) {
Map<String, dynamic> map = value.data;
DateTime dt = (map['dateOfPurchase'] as Timestamp).toDate();
print(dt);
});
The data
that the map['dateOfPurchase']
attribut containes: {_nanoseconds: 665000000, _seconds: 1659266068}
The exception
i get :
[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: type '_InternalLinkedHashMap<Object?, Object?>' is not a subtype of type 'Timestamp' in type cast