Event.fromJson constructor

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

Factory constructor to create an Event from a JSON object.

Implementation

factory Event.fromJson(Map<String, dynamic> json) {
  if (!json.containsKey('id') ||
      !json.containsKey('timestamp') ||
      !json.containsKey('details')) {
    throw ArgumentError('Missing required event fields.');
  }

  return Event(
    id: json['id'] as String,
    timestamp: json['timestamp'] as String,
    details: json['details'] as Map<String, dynamic>,
  );
}