track property Null safety
inherited
Implementation
Track? track;
override
Implementation
@override
set track(Track? newValue) {
if (super.track != newValue) {
logger.fine('setTrack ${newValue} $sid ${objectId}');
// dispose previous track (if exists)
super.track?.dispose();
super.track = newValue;
// Only listen for visibility updates if video optimization is on
// and the attached track is a video track
if (_participant.engine.connectOptions.optimizeVideo &&
newValue != null &&
newValue.kind == lk_models.TrackType.VIDEO) {
//
// Attach visibility event listener (if video track)
//
final listener = newValue.createListener();
listener.on<TrackVisibilityUpdatedEvent>(
_onVideoRendererVisibilityUpdateEvent);
newValue.onDispose(() async {
await listener.dispose();
// consider all views are disposed when track is null
_visibilities.clear();
if (!isDisposed) _visibilityDidUpdate?.call(null);
});
}
}
}