import 'package:json_annotation/json_annotation.dart'; part 'debt_person.g.dart'; @JsonSerializable() /// Represents a single person in a debt scenario class DebtPerson { /// Represents a single person in a debt scenario DebtPerson({required this.id, required this.name}); /// Default [DebtPerson] instance for json_serializable factory DebtPerson.unknownPerson() => DebtPerson(id: -1, name: "Unknown"); /// Generates a class instance from a Map factory DebtPerson.fromJson(Map json) => _$DebtPersonFromJson(json); /// Converts the data in this instance into a Map Map toJson() => _$DebtPersonToJson(this); /// Unique identifier @JsonKey(required: true, disallowNullValue: true) final int id; /// Identifier that the user will see @JsonKey(defaultValue: "Unknown") String name; }