fromJson static method

CallStatsParticipantSession? fromJson(
  1. dynamic value
)

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

Implementation

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

    return CallStatsParticipantSession(
      browser: mapValueOfType<String>(json, r'browser'),
      browserVersion: mapValueOfType<String>(json, r'browser_version'),
      cqScore: mapValueOfType<int>(json, r'cq_score'),
      currentIp: mapValueOfType<String>(json, r'current_ip'),
      currentSfu: mapValueOfType<String>(json, r'current_sfu'),
      distanceToSfuKilometers:
          mapValueOfType<double>(json, r'distance_to_sfu_kilometers'),
      endedAt: mapDateTime(json, r'ended_at', r''),
      freezesDurationMs: mapValueOfType<int>(json, r'freezes_duration_ms'),
      isLive: mapValueOfType<bool>(json, r'is_live')!,
      jitterMs: mapValueOfType<int>(json, r'jitter_ms'),
      latencyMs: mapValueOfType<int>(json, r'latency_ms'),
      location: CallStatsLocation.fromJson(json[r'location']),
      os: mapValueOfType<String>(json, r'os'),
      publishedTracks:
          PublishedTrackFlags.fromJson(json[r'published_tracks'])!,
      publisherType: mapValueOfType<String>(json, r'publisher_type'),
      sdk: mapValueOfType<String>(json, r'sdk'),
      sdkVersion: mapValueOfType<String>(json, r'sdk_version'),
      startedAt: mapDateTime(json, r'started_at', r''),
      unifiedSessionId: mapValueOfType<String>(json, r'unified_session_id'),
      userSessionId: mapValueOfType<String>(json, r'user_session_id')!,
      webrtcVersion: mapValueOfType<String>(json, r'webrtc_version'),
    );
  }
  return null;
}