1. @override
dynamic convertToPrimitiveValue(value)

Converts a value from a more complex value into a primitive value according to this instance's definition.

This method takes a Dart representation of a value and converts it to something that can be used elsewhere (e.g. an HTTP body or database query). How this value is computed depends on this instance's definition.

Source

@override
dynamic convertToPrimitiveValue(dynamic value) {
  if (value is DateTime) {
    return value.toIso8601String();
  } else if (isEnumeratedValue) {
    // todo: optimize?
    return value.toString().split(".").last;
  }

  return value;
}