Ajout des options
This commit is contained in:
42
em2rp/lib/models/option_model.dart
Normal file
42
em2rp/lib/models/option_model.dart
Normal file
@ -0,0 +1,42 @@
|
||||
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,
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user