fromJson static method
Returns a new CallStatsParticipant instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static CallStatsParticipant? 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'sessions'),
'Required key "CallStatsParticipant[sessions]" is missing from JSON.');
assert(json[r'sessions'] != null,
'Required key "CallStatsParticipant[sessions]" has a null value in JSON.');
assert(json.containsKey(r'user_id'),
'Required key "CallStatsParticipant[user_id]" is missing from JSON.');
assert(json[r'user_id'] != null,
'Required key "CallStatsParticipant[user_id]" has a null value in JSON.');
return true;
}());
return CallStatsParticipant(
latestActivityAt: mapDateTime(json, r'latest_activity_at', r''),
name: mapValueOfType<String>(json, r'name'),
roles: json[r'roles'] is Iterable
? (json[r'roles'] as Iterable)
.cast<String>()
.toList(growable: false)
: const [],
sessions: CallStatsParticipantSession.listFromJson(json[r'sessions']),
userId: mapValueOfType<String>(json, r'user_id')!,
);
}
return null;
}