43 lines
1004 B
Dart
43 lines
1004 B
Dart
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
|
|
class EventOption {
|
|
final String id;
|
|
final String name;
|
|
final String details;
|
|
final double valMin;
|
|
final double valMax;
|
|
final List<DocumentReference> eventTypes;
|
|
|
|
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>? ?? [])
|
|
.whereType<DocumentReference>()
|
|
.toList(),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'name': name,
|
|
'details': details,
|
|
'valMin': valMin,
|
|
'valMax': valMax,
|
|
'eventTypes': eventTypes,
|
|
};
|
|
}
|
|
}
|