converters property

  1. @JsonKey(includeFromJson: false, includeToJson: false)
List<JsonConverter>? converters
final

A list of JsonConverter to apply to this class.

Writing:

@JsonSerializable(converters: [MyJsonConverter()])
class Example {...}

is equivalent to writing:

@JsonSerializable()
@MyJsonConverter()
class Example {...}

The main difference is that this allows reusing a custom JsonSerializable over multiple classes:

const myCustomAnnotation = JsonSerializable(
  converters: [MyJsonConverter()],
);

@myCustomAnnotation
class Example {...}

@myCustomAnnotation
class Another {...}

Implementation

@JsonKey(includeFromJson: false, includeToJson: false)
final List<JsonConverter>? converters;