fromJson static method
Returns a new LiveEvent instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static LiveEvent? 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'type'), 'Required key "LiveEvent[type]" is missing from JSON.');
assert(json[r'type'] != null, 'Required key "LiveEvent[type]" has a null value in JSON.');
return true;
}());
return LiveEvent(
type: LiveEventType.fromJson(json[r'type'])!,
timestamp: mapValueOfType<int>(json, r'timestamp'),
ts: mapValueOfType<int>(json, r'ts'),
broadcastId: mapValueOfType<String>(json, r'broadcastId'),
userId: mapValueOfType<String>(json, r'userId'),
badges: CommentUserBadgeInfo.listFromJson(json[r'badges']),
notification: UserNotification.fromJson(json[r'notification']),
vote: PubSubVote.fromJson(json[r'vote']),
comment: PubSubComment.fromJson(json[r'comment']),
feedPost: FeedPost.fromJson(json[r'feedPost']),
extraInfo: LiveEventExtraInfo.fromJson(json[r'extraInfo']),
config: mapValueOfType<Object>(json, r'config'),
isClosed: mapValueOfType<bool>(json, r'isClosed'),
uj: json[r'uj'] is Iterable
? (json[r'uj'] as Iterable).cast<String>().toList(growable: false)
: const [],
ul: json[r'ul'] is Iterable
? (json[r'ul'] as Iterable).cast<String>().toList(growable: false)
: const [],
sc: mapValueOfType<int>(json, r'sc'),
changes: mapCastOfType<String, int>(json, r'changes') ?? const {},
);
}
return null;
}