fromJson static method
Returns a new ParticipantSessionDetails instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static ParticipantSessionDetails? 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'publisher_type'),
'Required key "ParticipantSessionDetails[publisher_type]" is missing from JSON.');
assert(json[r'publisher_type'] != null,
'Required key "ParticipantSessionDetails[publisher_type]" has a null value in JSON.');
assert(json.containsKey(r'roles'),
'Required key "ParticipantSessionDetails[roles]" is missing from JSON.');
assert(json[r'roles'] != null,
'Required key "ParticipantSessionDetails[roles]" has a null value in JSON.');
assert(json.containsKey(r'user_id'),
'Required key "ParticipantSessionDetails[user_id]" is missing from JSON.');
assert(json[r'user_id'] != null,
'Required key "ParticipantSessionDetails[user_id]" has a null value in JSON.');
assert(json.containsKey(r'user_session_id'),
'Required key "ParticipantSessionDetails[user_session_id]" is missing from JSON.');
assert(json[r'user_session_id'] != null,
'Required key "ParticipantSessionDetails[user_session_id]" has a null value in JSON.');
return true;
}());
return ParticipantSessionDetails(
durationInSeconds: mapValueOfType<int>(json, r'duration_in_seconds'),
joinedAt: mapDateTime(json, r'joined_at', r''),
leftAt: mapDateTime(json, r'left_at', r''),
publisherType: mapValueOfType<String>(json, r'publisher_type')!,
roles: json[r'roles'] is Iterable
? (json[r'roles'] as Iterable)
.cast<String>()
.toList(growable: false)
: const [],
userId: mapValueOfType<String>(json, r'user_id')!,
userSessionId: mapValueOfType<String>(json, r'user_session_id')!,
);
}
return null;
}