toJson property

Function? toJson

A Function to use when encoding the annotated field to JSON.

Must be a top-level or static Function or a constructor that accepts one positional argument compatible with the field being serialized that returns a JSON-compatible value.

When creating a class that supports both toJson and fromJson (the default), you should also set fromJson if you set toJson. Values returned by toJson should "round-trip" through fromJson.


final Function? toJson;