fromJson static method

CallStatsMapSubscriber? fromJson(
  1. dynamic value
)

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

Implementation

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

    return CallStatsMapSubscriber(
      isLive: mapValueOfType<bool>(json, r'is_live')!,
      location: CallStatsLocation.fromJson(json[r'location']),
      name: mapValueOfType<String>(json, r'name'),
      userId: mapValueOfType<String>(json, r'user_id')!,
      userSessionId: mapValueOfType<String>(json, r'user_session_id')!,
    );
  }
  return null;
}