InteractionEvent.fromJson constructor

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

Create an interaction event from a JSON map

Implementation

factory InteractionEvent.fromJson(Map<String, dynamic> json) {
  return InteractionEvent(
    widgetId: json['widgetId'],
    type: InteractionType.values.firstWhere(
      (e) => e.toString().split('.').last == json['type'],
      orElse: () => InteractionType.custom,
    ),
    value: json['value'],
    timestamp: DateTime.parse(json['timestamp']),
  );
}