fromJson static method

CallTranscription? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static CallTranscription? 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'end_time'),
          'Required key "CallTranscription[end_time]" is missing from JSON.');
      assert(json[r'end_time'] != null,
          'Required key "CallTranscription[end_time]" has a null value in JSON.');
      assert(json.containsKey(r'filename'),
          'Required key "CallTranscription[filename]" is missing from JSON.');
      assert(json[r'filename'] != null,
          'Required key "CallTranscription[filename]" has a null value in JSON.');
      assert(json.containsKey(r'session_id'),
          'Required key "CallTranscription[session_id]" is missing from JSON.');
      assert(json[r'session_id'] != null,
          'Required key "CallTranscription[session_id]" has a null value in JSON.');
      assert(json.containsKey(r'start_time'),
          'Required key "CallTranscription[start_time]" is missing from JSON.');
      assert(json[r'start_time'] != null,
          'Required key "CallTranscription[start_time]" has a null value in JSON.');
      assert(json.containsKey(r'url'),
          'Required key "CallTranscription[url]" is missing from JSON.');
      assert(json[r'url'] != null,
          'Required key "CallTranscription[url]" has a null value in JSON.');
      return true;
    }());

    return CallTranscription(
      endTime: mapDateTime(json, r'end_time', r'')!,
      filename: mapValueOfType<String>(json, r'filename')!,
      sessionId: mapValueOfType<String>(json, r'session_id')!,
      startTime: mapDateTime(json, r'start_time', r'')!,
      url: mapValueOfType<String>(json, r'url')!,
    );
  }
  return null;
}