2024-07-17 16:44:02 +02:00
|
|
|
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});
|
|
|
|
|
2024-07-17 17:37:41 +02:00
|
|
|
/// Default [DebtPerson] instance for json_serializable
|
|
|
|
factory DebtPerson.unknownPerson() => DebtPerson(id: -1, name: "Unknown");
|
|
|
|
|
2024-07-17 16:44:02 +02:00
|
|
|
/// Generates a class instance from a Map
|
|
|
|
factory DebtPerson.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$DebtPersonFromJson(json);
|
|
|
|
|
|
|
|
/// Converts the data in this instance into a Map
|
|
|
|
Map<String, dynamic> toJson() => _$DebtPersonToJson(this);
|
|
|
|
|
|
|
|
/// Unique identifier
|
2024-07-17 17:37:41 +02:00
|
|
|
@JsonKey(required: true, disallowNullValue: true)
|
2024-07-17 16:44:02 +02:00
|
|
|
final int id;
|
|
|
|
|
|
|
|
/// Identifier that the user will see
|
2024-07-17 17:37:41 +02:00
|
|
|
@JsonKey(defaultValue: "Unknown")
|
2024-07-17 16:44:02 +02:00
|
|
|
String name;
|
|
|
|
}
|