fromJson static method
Returns a new ChatTutor instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static ChatTutor? 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 "ChatTutor[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "ChatTutor[$key]" has a null value in JSON.');
});
return true;
}());
return ChatTutor(
id: mapValueOfType<int>(json, r'id'),
firstName: mapValueOfType<String>(json, r'first_name'),
name: mapValueOfType<String>(json, r'name')!,
photo: mapValueOfType<String>(json, r'photo')!,
isHidden: mapValueOfType<bool>(json, r'is_hidden')!,
isActive: mapValueOfType<bool>(json, r'is_active')!,
slug: mapValueOfType<String>(json, r'slug')!,
hasWhiteboardAccess: mapValueOfType<bool>(json, r'has_whiteboard_access')!,
photoThumbnail: mapValueOfType<String>(json, r'photo_thumbnail')!,
enableTrial: mapValueOfType<bool>(json, r'enable_trial')!,
enableInstant: mapValueOfType<bool>(json, r'enable_instant')!,
availability: mapValueOfType<String>(json, r'availability'),
timeOff: mapValueOfType<String>(json, r'time_off'),
userTimezone: mapValueOfType<String>(json, r'user_timezone')!,
hasStripeAccount: mapValueOfType<bool>(json, r'has_stripe_account')!,
);
}
return null;
}