fromJson static method

GifSearchResponse? fromJson(
  1. dynamic value
)

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

Implementation

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

    return GifSearchResponse(
      images: json[r'images'] is List
        ? (json[r'images'] as List).map((e) =>
            GifSearchResponseImagesInnerInner.listFromJson(json[r'images'])
          ).toList()
        :  const [],
      status: APIStatus.fromJson(json[r'status'])!,
    );
  }
  return null;
}