How does FlutterFire Cloud FireStore handle Dart DateTime and enum?

258 Views Asked by At

I can't find any data type reference guide that explains how Flutter (Dart) 'DateTime' and 'enum' data types should be represented in the Map structure passed to a FlutterFire FireStore add/update document call.

Any suggestions?

1

There are 1 best solutions below

0
maxmitz On

Here is an answer to another question about enums:

Flutter is able to generate JSON serialization code. It references the package json_annotation. It contains also support for enum serialization. So all you need is to use this tool and annotate your enum values with @JsonValue.

From the code docs:

An annotation is used to specify how an enum value is serialized.

For time objects the answer is from here:

Use

FieldValue.serverTimestamp()