fromJson static method
Returns a new CustomerProfile instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static CustomerProfile? 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 "CustomerProfile[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "CustomerProfile[$key]" has a null value in JSON.');
});
return true;
}());
return CustomerProfile(
firstName: mapValueOfType<String>(json, r'first_name'),
lastName: mapValueOfType<String>(json, r'last_name'),
displayName: mapValueOfType<String>(json, r'display_name')!,
fullName: mapValueOfType<String>(json, r'full_name')!,
feedbackRequiredCount: mapValueOfType<int>(json, r'feedback_required_count')!,
phoneNumber: mapValueOfType<String>(json, r'phone_number'),
isPhoneConfirmed: mapValueOfType<bool>(json, r'is_phone_confirmed'),
ref: mapValueOfType<String>(json, r'ref'),
hasCreditCard: mapValueOfType<bool>(json, r'has_credit_card'),
gender: mapValueOfType<String>(json, r'gender'),
skypeAddress: mapValueOfType<String>(json, r'skype_address'),
rating: mapValueOfType<int>(json, r'rating'),
photo: mapValueOfType<String>(json, r'photo'),
interests: json[r'interests'] is Iterable
? (json[r'interests'] as Iterable).cast<int>().toList(growable: false)
: const [],
emailVerified: mapValueOfType<bool>(json, r'email_verified'),
email: mapValueOfType<String>(json, r'email')!,
);
}
return null;
}