fromJson static method

PricingPlan? fromJson(
  1. dynamic value
)

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

Implementation

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

    return PricingPlan(
      key: mapValueOfType<String>(json, r'key')!,
      name: mapValueOfType<String>(json, r'name')!,
      price: mapValueOfType<double>(json, r'price')!,
      priceOnRequest: mapValueOfType<bool>(json, r'price_on_request'),
      projectQuotas: mapValueOfType<int>(json, r'project_quotas') ?? 0,
      projectQuotasDisabled: mapValueOfType<bool>(json, r'project_quotas_disabled'),
      modelQuotas: mapValueOfType<String>(json, r'model_quotas') ?? '0',
      modelQuotasDisabled: mapValueOfType<bool>(json, r'model_quotas_disabled'),
      seoOptimization: mapValueOfType<bool>(json, r'seo_optimization'),
      viewReporting: mapValueOfType<bool>(json, r'view_reporting'),
      customQrCodes: mapValueOfType<bool>(json, r'custom_qr_codes'),
      scenesApp: mapValueOfType<bool>(json, r'scenes_app'),
      hidden: mapValueOfType<bool>(json, r'hidden'),
    );
  }
  return null;
}