fromJson static method
Returns a new MortgageOfferDetails instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static MortgageOfferDetails? 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'interestRate'),
'Required key "MortgageOfferDetails[interestRate]" is missing from JSON.');
assert(json[r'interestRate'] != null,
'Required key "MortgageOfferDetails[interestRate]" has a null value in JSON.');
assert(json.containsKey(r'loanType'),
'Required key "MortgageOfferDetails[loanType]" is missing from JSON.');
assert(json[r'loanType'] != null,
'Required key "MortgageOfferDetails[loanType]" has a null value in JSON.');
assert(json.containsKey(r'priceAdjustment'),
'Required key "MortgageOfferDetails[priceAdjustment]" is missing from JSON.');
assert(json[r'priceAdjustment'] != null,
'Required key "MortgageOfferDetails[priceAdjustment]" has a null value in JSON.');
assert(json.containsKey(r'monthlyPayment'),
'Required key "MortgageOfferDetails[monthlyPayment]" is missing from JSON.');
assert(json[r'monthlyPayment'] != null,
'Required key "MortgageOfferDetails[monthlyPayment]" has a null value in JSON.');
assert(json.containsKey(r'netClosingCosts'),
'Required key "MortgageOfferDetails[netClosingCosts]" is missing from JSON.');
assert(json[r'netClosingCosts'] != null,
'Required key "MortgageOfferDetails[netClosingCosts]" has a null value in JSON.');
assert(json.containsKey(r'apr'),
'Required key "MortgageOfferDetails[apr]" is missing from JSON.');
assert(json[r'apr'] != null,
'Required key "MortgageOfferDetails[apr]" has a null value in JSON.');
assert(json.containsKey(r'loanTerm'),
'Required key "MortgageOfferDetails[loanTerm]" is missing from JSON.');
assert(json[r'loanTerm'] != null,
'Required key "MortgageOfferDetails[loanTerm]" has a null value in JSON.');
assert(json.containsKey(r'adjustmentType'),
'Required key "MortgageOfferDetails[adjustmentType]" is missing from JSON.');
assert(json[r'adjustmentType'] != null,
'Required key "MortgageOfferDetails[adjustmentType]" has a null value in JSON.');
return true;
}());
return MortgageOfferDetails(
interestRate: num.parse('${json[r'interestRate']}'),
loanType: MortgageLoanType.fromJson(json[r'loanType'])!,
priceAdjustment: num.parse('${json[r'priceAdjustment']}'),
monthlyPayment: num.parse('${json[r'monthlyPayment']}'),
netClosingCosts: num.parse('${json[r'netClosingCosts']}'),
apr: num.parse('${json[r'apr']}'),
loanTerm: mapValueOfType<int>(json, r'loanTerm')!,
adjustmentType:
MortgageAdjustmentType.fromJson(json[r'adjustmentType'])!,
);
}
return null;
}