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 toMap() { return { 'id': id, 'name': name, 'birthDate': birthDate.toIso8601String(), 'isLaying': isLaying, }; } factory Hen.fromMap(Map map) { return Hen( id: map['id'], name: map['name'], birthDate: DateTime.parse(map['birthDate']), isLaying: map['isLaying'] ?? true, ); } }