8000 fix: screen sharing issue for desktop. (#1490) · baihua666/flutter-webrtc@00ae261 · GitHub
[go: up one dir, main page]

Skip to content

Commit 00ae261

Browse files
authored
fix: screen sharing issue for desktop. (flutter-webrtc#1490)
1 parent 92843cb commit 00ae261

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

example/lib/src/widgets/screen_select_dialog.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:async';
2+
import 'dart:typed_data';
23

34
import 'package:flutter/material.dart';
45
import 'package:flutter_webrtc/flutter_webrtc.dart';
@@ -20,12 +21,14 @@ class ThumbnailWidget extends StatefulWidget {
2021

2122
class _ThumbnailWidgetState extends State<ThumbnailWidget> {
2223
final List<StreamSubscription> _subscriptions = [];
23-
24+
Uint8List? _thumbnail;
2425
@override
2526
void initState() {
2627
super.initState();
2728
_subscriptions.add(widget.source.onThumbnailChanged.stream.listen((event) {
28-
setState(() {});
29+
setState(() {
30+
_thumbnail = event;
31+
});
2932
}));
3033
_subscriptions.add(widget.source.onNameChanged.stream.listen((event) {
3134
setState(() {});
@@ -55,9 +58,9 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
5558
print('Selected source id => ${widget.source.id}');
5659
widget.onTap(widget.source);
5760
},
58-
child: widget.source.thumbnail != null
61+
child: _thumbnail != null
5962
? Image.memory(
60-
widget.source.thumbnail!,
63+
_thumbnail!,
6164
gaplessPlayback: true,
6265
alignment: Alignment.center,
6366
)
@@ -190,8 +193,8 @@ class ScreenSelectDialog extends Dialog {
190193
Container(
191194
constraints: BoxConstraints.expand(height: 24),
192195
child: TabBar(
193-
onTap: (value) => Future.delayed(
194-
Duration(milliseconds: 300), () {
196+
onTap: (value) =>
197+
Future.delayed(Duration.zero, () {
195198
_sourceType = value == 0
196199
? SourceType.Screen
197200
: SourceType.Window;

lib/src/native/desktop_capturer_impl.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@ class DesktopCapturerNative extends DesktopCapturer {
107107
}
108108
break;
109109
case 'desktopSourceRemoved':
110-
final source = _sources[map['id'] as String];
111-
if (source != null) {
112-
_sources.remove((source) => source.id == map['id']);
113-
_onRemoved.add(source);
110+
final id = map['id'] as String;
111+ 4E3D
if (_sources[id] != null) {
112+
_onRemoved.add(_sources.remove(id)!);
114113
}
115114
break;
116115
case 'desktopSourceThumbnailChanged':

0 commit comments

Comments
 (0)
0