fromJson static method

InboxListResponse? fromJson(
  1. dynamic value
)

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

Implementation

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

    return InboxListResponse(
      items: InboxItem.listFromJson(json[r'items']),
      totalCount: mapValueOfType<int>(json, r'totalCount')!,
      hasMore: mapValueOfType<bool>(json, r'hasMore')!,
    );
  }
  return null;
}