generics instead of covariant implementing for TrackPublication
This commit is contained in:
@@ -6,10 +6,7 @@ import '../proto/livekit_models.pb.dart' as lk_models;
|
||||
import '../track/local.dart';
|
||||
import 'track_publication.dart';
|
||||
|
||||
class LocalTrackPublication<T extends LocalTrack> extends TrackPublication {
|
||||
@override
|
||||
covariant T? track;
|
||||
|
||||
class LocalTrackPublication<T extends LocalTrack> extends TrackPublication<T> {
|
||||
@override
|
||||
final LocalParticipant participant;
|
||||
|
||||
@@ -27,7 +24,7 @@ class LocalTrackPublication<T extends LocalTrack> extends TrackPublication {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> updateTrack(covariant T? newValue) async {
|
||||
Future<bool> updateTrack(T? newValue) async {
|
||||
final didUpdate = await super.updateTrack(newValue);
|
||||
|
||||
if (newValue != null) {
|
||||
|
||||
@@ -30,10 +30,8 @@ class RendererVisibility {
|
||||
|
||||
/// Represents a track publication from a RemoteParticipant. Provides methods to
|
||||
/// control if we should subscribe to the track, and its quality (for video).
|
||||
class RemoteTrackPublication<T extends RemoteTrack> extends TrackPublication {
|
||||
@override
|
||||
covariant T? track;
|
||||
|
||||
class RemoteTrackPublication<T extends RemoteTrack>
|
||||
extends TrackPublication<T> {
|
||||
@override
|
||||
final RemoteParticipant participant;
|
||||
|
||||
|
||||
@@ -13,16 +13,16 @@ import '../types.dart';
|
||||
/// Base for [RemoteTrackPublication] and [LocalTrackPublication],
|
||||
/// can not be instantiated directly.
|
||||
|
||||
abstract class TrackPublication extends Disposable {
|
||||
abstract class TrackPublication<T extends Track> extends Disposable {
|
||||
final String sid;
|
||||
final String name;
|
||||
final lk_models.TrackType kind;
|
||||
final TrackSource source;
|
||||
|
||||
// Relevant type must be implemented
|
||||
abstract Track? track;
|
||||
/// The current [Track] for this publication (readonly).
|
||||
T? get track => _track;
|
||||
T? _track;
|
||||
|
||||
// Relevant type must be implemented
|
||||
/// The [Participant] this publication belongs to.
|
||||
abstract final Participant participant;
|
||||
|
||||
@@ -71,11 +71,11 @@ abstract class TrackPublication extends Disposable {
|
||||
// Returns true if value has changed.
|
||||
// Intended for internal use only.
|
||||
@internal
|
||||
Future<bool> updateTrack(Track? newValue) async {
|
||||
if (track == newValue) return false;
|
||||
Future<bool> updateTrack(T? newValue) async {
|
||||
if (_track == newValue) return false;
|
||||
// dispose previous track (if exists)
|
||||
await track?.dispose();
|
||||
track = newValue;
|
||||
await _track?.dispose();
|
||||
_track = newValue;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user