Files
client-sdk-flutter/lib/src/track/track_publication.dart
T
Hiroshi HorieandGitHub ab31ddabb9 Apply Flutter best practices [Non-Breaking] (#2)
* Add flutter_lints package

* Use key in widget constructors

lint: use_key_in_widget_constructors

* Unnecessary new keyword

lint: unnecessary_new

* Prefer const with constant constructors

* Exclude protobuf files from analyzer

* Private field could be final

* Annotate overridden members

* Use initializing formals when possible

* Don't access members with `this` unless avoiding shadowing

* Prefer is! operator

* Use isEmpty instead of length

* Use collection literals when possible

* Revert comment changes

* Cleaner null testing

* Misc fixes

* Avoid using `forEach` with a function literal

* Prefer `final` over `var` where applicable

* Enforce stricter type-checking

* Ignore VS Code files

* Flutter format

* Prefer using lowerCamelCase for constant names

* flutter format -l 100

* Disable `avoid_print` for examples

* Slight improvements to example

Should solve lint error: no_logic_in_create_state
2021-08-31 16:35:07 +09:00

35 lines
907 B
Dart

import '../proto/livekit_models.pb.dart';
import 'track.dart';
/// Represents a track that's published to the server. This class contains
/// metadata associated with tracks.
class TrackPublication {
Track? track;
String name;
String sid;
TrackType kind;
bool muted = false;
bool simulcasted = false;
TrackDimension? dimension;
bool get subscribed => track != null;
TrackPublication.fromInfo(TrackInfo info)
: sid = info.sid,
name = info.name,
kind = info.type {
updateFromInfo(info);
}
/// True when the track is published with name [Track.screenShareName].
bool get isScreenShare => kind == TrackType.VIDEO && name == Track.screenShareName;
void updateFromInfo(TrackInfo info) {
muted = info.muted;
simulcasted = info.simulcast;
if (info.type == TrackType.VIDEO) {
dimension = TrackDimension(info.width, info.height);
}
}
}