fromJson static method

LifeInsuranceOfferDetails? fromJson(
  1. dynamic value
)

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

Implementation

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

    return LifeInsuranceOfferDetails(
      policyAmount: mapValueOfType<int>(json, r'policyAmount')!,
      termLength: mapValueOfType<int>(json, r'termLength'),
      termUnit: TermUnit.fromJson(json[r'termUnit']),
      monthlyPremiumAmount: num.parse('${json[r'monthlyPremiumAmount']}'),
      annualPremiumAmount: num.parse('${json[r'annualPremiumAmount']}'),
      semiAnnualPremiumAmount:
          num.parse('${json[r'semiAnnualPremiumAmount']}'),
      onlineAppAvailable: mapValueOfType<bool>(json, r'onlineAppAvailable'),
      noMedicalTest: mapValueOfType<bool>(json, r'noMedicalTest'),
      packageType: PackageType.fromJson(json[r'packageType']),
      recommended: mapValueOfType<bool>(json, r'recommended'),
      medicalExam: MedicalExam.fromJson(json[r'medicalExam']),
      policyName: mapValueOfType<String>(json, r'policyName'),
      carrierDecisionType:
          CarrierDecisionType.fromJson(json[r'carrierDecisionType']),
      partnerQuoteId: mapValueOfType<String>(json, r'partnerQuoteId'),
      convertToPermanent: mapValueOfType<bool>(json, r'convertToPermanent'),
      childRider: mapValueOfType<String>(json, r'childRider'),
      acceleratedDeathBenefit:
          mapValueOfType<bool>(json, r'acceleratedDeathBenefit'),
      waiverOfPremium: mapValueOfType<String>(json, r'waiverOfPremium'),
      isOnlineApplication: mapValueOfType<bool>(json, r'isOnlineApplication'),
      deliveryMethod: mapValueOfType<String>(json, r'deliveryMethod'),
      examRequired: mapValueOfType<String>(json, r'examRequired'),
    );
  }
  return null;
}