fromJson static method

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

Implementation

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

    return GemShopCustomDesignPurchaseResponseDataSchema(
      code: mapValueOfType<String>(json, r'code')!,
      name: mapValueOfType<String>(json, r'name')!,
      gems: mapValueOfType<int>(json, r'gems')!,
      cost: mapValueOfType<int>(json, r'cost')!,
    );
  }
  return null;
}