How to add values to array from flutter to firestore

Viewed 367

In Firestore, I have a document with a field of type array, I want to add datetime values to it from flutter app. Can anyone suggest a way to do it?

1 Answers

Storing:

Use DateTime.now().millisecondsSinceEpoch

This would give you an int value in return that you can save in Firestore.

Retrieving:

You can easily get DateTime from the saved value using DateTime.fromMillisecondsSinceEpoch(valueSavedInFirestore)

Related