toJson property

String Function(T s)? toJson
getter/setter pair

Callback that exposes the current state and returns a String representation of the state.

If it is not defined,it will be inferred form primitive:

  • int: (int s)=> '$s';
  • double: (double s)=> '$s';
  • String: (String s)=> '$s';
  • bool: (bool s)=> s? '1' : '0';

If it is not defined and the model is not primitive, it will throw and ArgumentError.

Implementation

String Function(T s)? toJson;