48 lines
1.1 KiB
Dart
48 lines
1.1 KiB
Dart
class Messwert {
|
|
final int id;
|
|
final DateTime datum;
|
|
final int gewicht;
|
|
final String? behandlung;
|
|
final String? bemerkung;
|
|
|
|
Messwert({
|
|
required this.id,
|
|
required this.datum,
|
|
required this.gewicht,
|
|
this.behandlung,
|
|
this.bemerkung,
|
|
});
|
|
|
|
factory Messwert.fromMap(Map<String, dynamic> m) => Messwert(
|
|
id: (m['id'] as num).toInt(),
|
|
datum: DateTime.parse(m['datum'] as String).toLocal(),
|
|
gewicht: (m['gewicht'] as num).toInt(),
|
|
behandlung: m['behandlung'] as String?,
|
|
bemerkung: m['bemerkung'] as String?,
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
'id': id,
|
|
'datum': datum.toIso8601String(),
|
|
'gewicht': gewicht,
|
|
'behandlung': behandlung,
|
|
'bemerkung': bemerkung,
|
|
};
|
|
|
|
Messwert copyWith({
|
|
int? id,
|
|
DateTime? datum,
|
|
int? gewicht,
|
|
String? behandlung,
|
|
String? bemerkung,
|
|
}) {
|
|
return Messwert(
|
|
id: id ?? this.id,
|
|
datum: datum ?? this.datum,
|
|
gewicht: gewicht ?? this.gewicht,
|
|
behandlung: behandlung ?? this.behandlung,
|
|
bemerkung: bemerkung ?? this.bemerkung,
|
|
);
|
|
}
|
|
}
|