fromJson static method

EventLogEntry? fromJson(
  1. dynamic value
)

Returns a new EventLogEntry instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static EventLogEntry? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      assert(json.containsKey(r'_id'), 'Required key "EventLogEntry[_id]" is missing from JSON.');
      assert(json[r'_id'] != null, 'Required key "EventLogEntry[_id]" has a null value in JSON.');
      assert(json.containsKey(r'createdAt'), 'Required key "EventLogEntry[createdAt]" is missing from JSON.');
      assert(json[r'createdAt'] != null, 'Required key "EventLogEntry[createdAt]" has a null value in JSON.');
      assert(json.containsKey(r'tenantId'), 'Required key "EventLogEntry[tenantId]" is missing from JSON.');
      assert(json[r'tenantId'] != null, 'Required key "EventLogEntry[tenantId]" has a null value in JSON.');
      assert(json.containsKey(r'urlId'), 'Required key "EventLogEntry[urlId]" is missing from JSON.');
      assert(json[r'urlId'] != null, 'Required key "EventLogEntry[urlId]" has a null value in JSON.');
      assert(json.containsKey(r'broadcastId'), 'Required key "EventLogEntry[broadcastId]" is missing from JSON.');
      assert(json[r'broadcastId'] != null, 'Required key "EventLogEntry[broadcastId]" has a null value in JSON.');
      assert(json.containsKey(r'data'), 'Required key "EventLogEntry[data]" is missing from JSON.');
      assert(json[r'data'] != null, 'Required key "EventLogEntry[data]" has a null value in JSON.');
      return true;
    }());

    return EventLogEntry(
      id: mapValueOfType<String>(json, r'_id')!,
      createdAt: mapDateTime(json, r'createdAt', r'')!,
      tenantId: mapValueOfType<String>(json, r'tenantId')!,
      urlId: mapValueOfType<String>(json, r'urlId')!,
      broadcastId: mapValueOfType<String>(json, r'broadcastId')!,
      data: mapValueOfType<String>(json, r'data')!,
    );
  }
  return null;
}