@@ -61,8 +61,12 @@ class _StreamLobbyViewState extends State<StreamLobbyView> {
6161 StreamSubscription <Object >? _fetchSubscription;
6262 StreamSubscription <Object >? _eventSubscription;
6363
64+ bool get hasCameraEnabled => _cameraTrack != null ;
65+
66+ bool get hasMicrophoneEnabled => _microphoneTrack != null ;
67+
6468 Future <void > toggleCamera () async {
65- if (_cameraTrack != null ) {
69+ if (hasCameraEnabled ) {
6670 await _cameraTrack? .stop ();
6771 return setState (() => _cameraTrack = null );
6872 }
@@ -76,7 +80,7 @@ class _StreamLobbyViewState extends State<StreamLobbyView> {
7680 }
7781
7882 Future <void > toggleMicrophone () async {
79- if (_microphoneTrack != null ) {
83+ if (hasMicrophoneEnabled ) {
8084 await _microphoneTrack? .stop ();
8185 return setState (() => _microphoneTrack = null );
8286 }
@@ -91,20 +95,17 @@ class _StreamLobbyViewState extends State<StreamLobbyView> {
9195
9296 void onJoinCallPressed () {
9397 _isJoiningCall = true ;
94-
9598 var options = const CallConnectOptions ();
9699
97- final cameraTrack = _cameraTrack;
98- if (cameraTrack != null ) {
100+ if (hasCameraEnabled) {
99101 options = options.copyWith (
100- camera: TrackOption .provided (cameraTrack ),
102+ camera: TrackOption .enabled ( ),
101103 );
102104 }
103105
104- final microphoneTrack = _microphoneTrack;
105- if (microphoneTrack != null ) {
106+ if (hasMicrophoneEnabled) {
106107 options = options.copyWith (
107- microphone: TrackOption .provided (microphoneTrack ),
108+ microphone: TrackOption .enabled ( ),
108109 );
109110 }
110111
0 commit comments