IProovEvent.fromMap constructor

IProovEvent.fromMap(
  1. Map map
)

Implementation

factory IProovEvent.fromMap(Map map) {
  switch (map['event']) {
    case 'connecting':
      return connecting;
    case 'connected':
      return connected;
    case 'processing':
      return IProovEvent.progress(map['progress'], map['message']);
    case 'success':
      final frameData = map['frame'];
      final frame = frameData != null ? decodePng(frameData) as Image : null;
      return IProovEvent.success(map['token'], frame);
    case 'failure':
      final frameData = map['frame'];
      final frame = frameData != null ? decodePng(frameData) as Image : null;
      return IProovEvent.failure(
          map['token'], map['reason'], map['feedbackCode'], frame);
    case 'cancelled':
      return cancelled;
    case 'error':
      return IProovEvent.error(map['error'], map['title'], map['message']);
  }
  throw Exception('Invalid event');
}