fromJson property

FutureOr<T> Function(String json)? fromJson
getter/setter pair

Optional callback that exposes the String representation of the state and returns the parsed state.

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

  • int: (String json)=> int.parse(json);
  • double: (String json)=> double.parse(json);
  • String: (String json)=> json;
  • bool: (String json)=> json =='1';

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

Implementation

FutureOr<T> Function(String json)? fromJson;