fromJson static method
Client?
fromJson(
- dynamic value
)
Returns a new Client instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static Client? 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 "Client[$key]" is missing from JSON.');
assert(json[key] != null,
'Required key "Client[$key]" has a null value in JSON.');
});
return true;
}());
return Client(
object: ClientObjectEnum.fromJson(json[r'object'])!,
id: mapValueOfType<String>(json, r'id')!,
sessionIds: json[r'session_ids'] is Iterable
? (json[r'session_ids'] as Iterable)
.cast<String>()
.toList(growable: false)
: const [],
sessions: Session.listFromJson(json[r'sessions']),
signInId: mapValueOfType<String>(json, r'sign_in_id'),
signUpId: mapValueOfType<String>(json, r'sign_up_id'),
lastActiveSessionId:
mapValueOfType<String>(json, r'last_active_session_id'),
updatedAt: mapValueOfType<int>(json, r'updated_at')!,
createdAt: mapValueOfType<int>(json, r'created_at')!,
);
}
return null;
}