createToJson property

bool createToJson
final

If true (the default), code for encoding JSON is generated for this class.

If json_serializable is configured with generate_to_json_function: true (the default), a top-level function is created that you can reference from your class.

@JsonSerializable()
class Example {
  Map<String, dynamic> toJson() => _$ExampleToJson(this);
}

If json_serializable is configured with generate_to_json_function: false, a private _$ClassNameMixin class is created in the generated part file which contains a toJson method.

Mix in this class to the source class:

@JsonSerializable()
class Example extends Object with _$ExampleSerializerMixin {
  // ...
}

Implementation

final bool createToJson