parseAhapEventsFromJson function
Implementation
List<AhapEvent> parseAhapEventsFromJson(String ahap) {
List<AhapEvent> ahapEvents = [];
//parse ahap json
Map<String, dynamic> ahapJson;
try {
ahapJson = json.decode(ahap);
List events = ahapJson['Pattern'] as List;
for (var event in events) {
Map<String, dynamic> eventMap = event as Map<String, dynamic>;
List<AhapEvent> ahapEvent = AhapEvent.fromMap(eventMap);
ahapEvents.addAll(ahapEvent);
}
return ahapEvents;
} catch (e) {
throw Exception('Invalid AHAP JSON $e');
}
}