CameraEvent.fromJson constructor

CameraEvent.fromJson(
  1. Map<String, dynamic> json
)

Implementation

CameraEvent.fromJson(Map<String, dynamic> json) {
  if (json['eventType'] is int) {
    eventType = PlatformEvent.values[json['eventType']];
  } else {
    try {
      eventType = PlatformEvent.values.firstWhere(
          (e) => e.toString().split(".").last == json['eventType']);
    } on StateError {
      //When the list is empty or eventType not found (Bad State: No Element)
    } catch (e) {
      // TODO handle the error
    }
  }
}