part of '../neon_spreed.dart'; class SpreedScreenPreview extends StatefulWidget { const SpreedScreenPreview({ required this.source, super.key, }); final DesktopCapturerSource source; @override State createState() => _SpreedScreenPreviewState(); } class _SpreedScreenPreviewState extends State { late final List> subscriptions = []; @override void initState() { super.initState(); subscriptions.addAll([ widget.source.onThumbnailChanged.stream.listen((final _) => setState(() {})), widget.source.onNameChanged.stream.listen((final _) => setState(() {})), ]); } @override void dispose() { for (final subscription in subscriptions) { unawaited(subscription.cancel()); } super.dispose(); } @override Widget build(final BuildContext context) => Column( children: [ if (widget.source.thumbnail != null) ...[ AspectRatio( aspectRatio: 3 / 2, child: Image.memory( widget.source.thumbnail!, gaplessPlayback: true, fit: BoxFit.contain, ), ), ], Text( widget.source.name, maxLines: 2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.center, style: const TextStyle( fontWeight: FontWeight.bold, ), ), ], ); }