Skip to content

Commit

Permalink
fix preview bug for desktop screen share. (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc authored Dec 1, 2023
1 parent 4012b53 commit d684856
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions lib/src/widgets/screen_select_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,26 @@ class ThumbnailWidget extends StatefulWidget {

class ThumbnailWidgetState extends State<ThumbnailWidget> {
final List<StreamSubscription> _subscriptions = [];
Uint8List? _thumbnail;
String _name = '';

@override
void initState() {
super.initState();
_subscriptions.add(widget.source.onThumbnailChanged.stream.listen((event) {
setState(() {});
_name = widget.source.name;
_thumbnail = widget.source.thumbnail?.isNotEmpty == true
? widget.source.thumbnail
: null;
_subscriptions
.add(widget.source.onThumbnailChanged.stream.listen((thumbnail) {
setState(() {
_thumbnail = thumbnail;
});
}));
_subscriptions.add(widget.source.onNameChanged.stream.listen((event) {
setState(() {});
_subscriptions.add(widget.source.onNameChanged.stream.listen((name) {
setState(() {
_name = name;
});
}));
}

Expand Down Expand Up @@ -73,17 +84,17 @@ class ThumbnailWidgetState extends State<ThumbnailWidget> {
}
widget.onTap(widget.source);
},
child: widget.source.thumbnail != null
child: _thumbnail != null
? Image.memory(
widget.source.thumbnail!,
_thumbnail!,
gaplessPlayback: true,
alignment: Alignment.center,
)
: Container(),
),
)),
Text(
widget.source.name,
_name,
style: TextStyle(
fontSize: 12,
color: Colors.black87,
Expand Down

0 comments on commit d684856

Please sign in to comment.