fromJson static method

ReportResponse? fromJson(
  1. dynamic value
)

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

Implementation

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

    return ReportResponse(
      call: CallReportResponse.fromJson(json[r'call'])!,
      participants:
          ParticipantReportResponse.fromJson(json[r'participants'])!,
      userRatings: UserRatingReportResponse.fromJson(json[r'user_ratings'])!,
    );
  }
  return null;
}