ObslyEvent.fromJson constructor

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

Implementation

factory ObslyEvent.fromJson(Map<String, dynamic> json) {
  return JsonFactoryMixin.safeFromJson(
    json,
    (j) => ObslyEvent(
      installationId: j['installation_id'] ?? '',
      executionId: j['execution_id'],
      timestamp: JsonFactoryMixin.safeDateTime(j['timestamp']) ??
          DateTime.now().toUtc(),
      sessionId: j['session_id'] ?? '',
      eventId: j['event_id'] ?? const Uuid().v4(),
      sequence: JsonFactoryMixin.safeInt(j['sequence']) ?? 0,
      type: JsonFactoryMixin.safeInt(j['type']) ?? 0,
      name: j['name'],
      extra: j['extra'] != null ? ObslyEventExtra.fromJson(j['extra']) : null,
      bg: j['bg'] == true,
      processStep: j['process_step'],
    ),
    () => ObslyEvent(
      installationId: '',
      timestamp: DateTime.now().toUtc(),
      sessionId: '',
      eventId: const Uuid().v4(),
      sequence: 0,
      type: 0,
      bg: false,
    ),
  );
}