42 lines
1.0 KiB
Dart
42 lines
1.0 KiB
Dart
|
|
class EventOption {
|
|
final String id;
|
|
final String name;
|
|
final String details;
|
|
final double valMin;
|
|
final double valMax;
|
|
final List<String> eventTypes; // Changé de List<DocumentReference> à List<String>
|
|
|
|
EventOption({
|
|
required this.id,
|
|
required this.name,
|
|
required this.details,
|
|
required this.valMin,
|
|
required this.valMax,
|
|
required this.eventTypes,
|
|
});
|
|
|
|
factory EventOption.fromMap(Map<String, dynamic> map, String id) {
|
|
return EventOption(
|
|
id: id,
|
|
name: map['name'] ?? '',
|
|
details: map['details'] ?? '',
|
|
valMin: (map['valMin'] ?? 0.0).toDouble(),
|
|
valMax: (map['valMax'] ?? 0.0).toDouble(),
|
|
eventTypes: (map['eventTypes'] as List<dynamic>? ?? [])
|
|
.map((e) => e.toString()) // Convertit en String (supporte IDs et références)
|
|
.toList(),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'name': name,
|
|
'details': details,
|
|
'valMin': valMin,
|
|
'valMax': valMax,
|
|
'eventTypes': eventTypes,
|
|
};
|
|
}
|
|
}
|