fromJson static method
Returns a new TutorProfile instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static TutorProfile? 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 "TutorProfile[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "TutorProfile[$key]" has a null value in JSON.');
});
return true;
}());
return TutorProfile(
qualifications: TutorQualification.listFromJson(json[r'qualifications']),
video: mapValueOfType<String>(json, r'video'),
videoLink: mapValueOfType<String>(json, r'video_link'),
photo: mapValueOfType<String>(json, r'photo'),
postcode: mapValueOfType<String>(json, r'postcode'),
tagline: mapValueOfType<String>(json, r'tagline'),
subjects: TutorSubject.listFromJson(json[r'subjects']),
availability: TutorAvailability.listFromJson(json[r'availability']),
timeOff: TutorTimeOff.listFromJson(json[r'time_off']),
dbsNumber: mapValueOfType<String>(json, r'dbs_number'),
experience: mapValueOfType<String>(json, r'experience'),
experienceYears: mapValueOfType<int>(json, r'experience_years'),
personalityType: mapValueOfType<String>(json, r'personality_type') ?? '',
address: mapValueOfType<String>(json, r'address'),
profilePhotoRejected: mapValueOfType<bool>(json, r'profile_photo_rejected'),
onlineTutoring: mapValueOfType<bool>(json, r'online_tutoring'),
inPersonTutoring: mapValueOfType<bool>(json, r'in_person_tutoring'),
tutorProfileId: mapValueOfType<int>(json, r'tutor_profile_id')!,
enableTrial: mapValueOfType<bool>(json, r'enable_trial'),
enableInstant: mapValueOfType<bool>(json, r'enable_instant'),
liveSessionType: LiveSessionTypeEnum.fromJson(json[r'live_session_type']),
school: mapValueOfType<int>(json, r'school'),
schoolName: mapValueOfType<String>(json, r'school_name') ?? '',
statementConfirmation: mapValueOfType<bool>(json, r'statement_confirmation'),
handbook: mapValueOfType<bool>(json, r'handbook'),
tutorIDImage: mapValueOfType<String>(json, r'tutor_ID_image'),
tutorCv: mapValueOfType<String>(json, r'tutor_cv'),
country: mapValueOfType<int>(json, r'country'),
id: mapValueOfType<int>(json, r'id'),
user: UserUpdate.fromJson(json[r'user'])!,
hasBackendPhoto: mapValueOfType<bool>(json, r'has_backend_photo'),
isSuperTutor: mapValueOfType<bool>(json, r'is_super_tutor'),
hasStripeAccount: mapValueOfType<bool>(json, r'has_stripe_account'),
isDbsChecked: mapValueOfType<bool>(json, r'is_dbs_checked'),
incompleteSections: json[r'incomplete_sections'] is Iterable
? (json[r'incomplete_sections'] as Iterable).cast<String>().toList(growable: false)
: const [],
isLive: mapValueOfType<bool>(json, r'is_live'),
hasWhiteboardAccess: mapValueOfType<bool>(json, r'has_whiteboard_access'),
isHidden: mapValueOfType<bool>(json, r'is_hidden'),
coverage: json[r'coverage'] is Iterable
? (json[r'coverage'] as Iterable).cast<int>().toList(growable: false)
: const [],
completedSections: json[r'completed_sections'] is Iterable
? (json[r'completed_sections'] as Iterable).cast<String>().toList(growable: false)
: const [],
metInPerson: mapValueOfType<bool>(json, r'met_in_person'),
numReviews: mapValueOfType<int>(json, r'num_reviews') ?? 0,
responseTimeDisplay: mapValueOfType<String>(json, r'response_time_display') ?? '',
profileSubmitted: mapValueOfType<bool>(json, r'profile_submitted'),
userTimezone: mapValueOfType<String>(json, r'user_timezone') ?? '',
);
}
return null;
}