json_serializable.dart icon indicating copy to clipboard operation
json_serializable.dart copied to clipboard

Support annotations on ctor params when there is no associated field

Open kevmoo opened this issue 7 years ago • 0 comments

See https://github.com/dart-lang/json_serializable/issues/285#issuecomment-415609028

@JsonSerializable(createToJson: false)
class LogisticsItem {
  final bool logisticsChecked;
  final bool logisticsOK;

  LogisticsItem(@JsonKey(name: 'LogistikTeileInOrdnung') String processed)
      : logisticsChecked = processed != null && processed != 'null',
        logisticsOK = processed == 'true';
}

kevmoo avatar Aug 24 '18 23:08 kevmoo