32 lines
601 B
Dart
32 lines
601 B
Dart
class Hen {
|
|
final String id;
|
|
final String name;
|
|
final DateTime birthDate;
|
|
bool isLaying;
|
|
|
|
Hen({
|
|
required this.id,
|
|
required this.name,
|
|
required this.birthDate,
|
|
this.isLaying = true,
|
|
});
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'id': id,
|
|
'name': name,
|
|
'birthDate': birthDate.toIso8601String(),
|
|
'isLaying': isLaying,
|
|
};
|
|
}
|
|
|
|
factory Hen.fromMap(Map<String, dynamic> map) {
|
|
return Hen(
|
|
id: map['id'],
|
|
name: map['name'],
|
|
birthDate: DateTime.parse(map['birthDate']),
|
|
isLaying: map['isLaying'] ?? true,
|
|
);
|
|
}
|
|
}
|