toJson property
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 behavior), it is recommended to also set fromJson if
toJson is set. Values returned by toJson should "round-trip" through
fromJson.
Implementation
final Function? toJson;