From c323195a67c31568f0e36eafd5d12a35098f3756 Mon Sep 17 00:00:00 2001 From: Jeff Peiffer Date: Wed, 3 Jan 2024 18:57:19 -0500 Subject: [PATCH] remove web_socket_channel_connect --- CHANGELOG.md | 5 ++ analysis_options.yaml | 53 +--------------------- examples/receiver/analysis_options.yaml | 53 +--------------------- examples/receiver/pubspec.yaml | 2 + examples/sender/analysis_options.yaml | 53 +--------------------- examples/sender/pubspec.yaml | 2 + lib/src/web_rtc/screen_select_dialog.dart | 41 +++++++++-------- lib/src/web_rtc/screen_sender.dart | 6 +-- lib/src/widget/remote_screen_renderer.dart | 4 +- pubspec.yaml | 23 +++++----- 10 files changed, 53 insertions(+), 189 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58f04b7..a4b7dc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [1.0.1] - January 3rd, 2024 + +* Removed unnecessary `web_socket_channel_connect` dependency + + ## [1.0.0+28] - December 5, 2023 * Automated dependency updates diff --git a/analysis_options.yaml b/analysis_options.yaml index e86e0b8..cc6f1cb 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,70 +1,21 @@ +include: package:flutter_lints/flutter.yaml + linter: rules: - always_declare_return_types - - always_require_non_null_named_parameters - - annotate_overrides - - avoid_empty_else - avoid_equals_and_hash_code_on_mutable_classes - avoid_escaping_inner_quotes - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_print - - avoid_relative_lib_imports - - avoid_return_types_on_setters - - avoid_shadowing_type_parameters - avoid_slow_async_io - - avoid_types_as_parameter_names - - avoid_unnecessary_containers - - avoid_unused_constructor_parameters - - camel_case_extensions - - camel_case_types - cancel_subscriptions - close_sinks - - curly_braces_in_flow_control_structures - directives_ordering - - empty_catches - empty_constructor_bodies - - implementation_imports - - library_names - - library_prefixes - - no_duplicate_case_values - - null_closures - omit_local_variable_types - - package_names - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_conditional_assignment - - prefer_contains - - prefer_const_constructors - - prefer_final_fields - prefer_final_locals - - prefer_for_elements_to_map_fromIterable - - prefer_generic_function_type_aliases - - prefer_if_null_operators - - prefer_interpolation_to_compose_strings - - prefer_is_empty - - prefer_is_not_empty - - prefer_iterable_whereType - prefer_single_quotes - - prefer_spread_collections - - prefer_typing_uninitialized_variables - - prefer_void_to_null - - recursive_getters - - slash_for_doc_comments - sort_child_properties_last - sort_constructors_first - sort_pub_dependencies - sort_unnamed_constructors_first - - type_init_formals - unawaited_futures - - unnecessary_const - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_null_in_if_null_operators - - unnecessary_this - - unrelated_type_equality_checks - use_full_hex_values_for_flutter_colors - - use_function_type_syntax_for_parameters - - use_rethrow_when_possible - - valid_regexps - - void_checks diff --git a/examples/receiver/analysis_options.yaml b/examples/receiver/analysis_options.yaml index e86e0b8..cc6f1cb 100644 --- a/examples/receiver/analysis_options.yaml +++ b/examples/receiver/analysis_options.yaml @@ -1,70 +1,21 @@ +include: package:flutter_lints/flutter.yaml + linter: rules: - always_declare_return_types - - always_require_non_null_named_parameters - - annotate_overrides - - avoid_empty_else - avoid_equals_and_hash_code_on_mutable_classes - avoid_escaping_inner_quotes - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_print - - avoid_relative_lib_imports - - avoid_return_types_on_setters - - avoid_shadowing_type_parameters - avoid_slow_async_io - - avoid_types_as_parameter_names - - avoid_unnecessary_containers - - avoid_unused_constructor_parameters - - camel_case_extensions - - camel_case_types - cancel_subscriptions - close_sinks - - curly_braces_in_flow_control_structures - directives_ordering - - empty_catches - empty_constructor_bodies - - implementation_imports - - library_names - - library_prefixes - - no_duplicate_case_values - - null_closures - omit_local_variable_types - - package_names - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_conditional_assignment - - prefer_contains - - prefer_const_constructors - - prefer_final_fields - prefer_final_locals - - prefer_for_elements_to_map_fromIterable - - prefer_generic_function_type_aliases - - prefer_if_null_operators - - prefer_interpolation_to_compose_strings - - prefer_is_empty - - prefer_is_not_empty - - prefer_iterable_whereType - prefer_single_quotes - - prefer_spread_collections - - prefer_typing_uninitialized_variables - - prefer_void_to_null - - recursive_getters - - slash_for_doc_comments - sort_child_properties_last - sort_constructors_first - sort_pub_dependencies - sort_unnamed_constructors_first - - type_init_formals - unawaited_futures - - unnecessary_const - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_null_in_if_null_operators - - unnecessary_this - - unrelated_type_equality_checks - use_full_hex_values_for_flutter_colors - - use_function_type_syntax_for_parameters - - use_rethrow_when_possible - - valid_regexps - - void_checks diff --git a/examples/receiver/pubspec.yaml b/examples/receiver/pubspec.yaml index fa4134c..5e8cda7 100644 --- a/examples/receiver/pubspec.yaml +++ b/examples/receiver/pubspec.yaml @@ -10,10 +10,12 @@ environment: dependencies: flutter: sdk: flutter + logging: '^1.2.0' screen_streamer: path: ../../ dev_dependencies: + flutter_lints: '^3.0.1' flutter_test: sdk: flutter diff --git a/examples/sender/analysis_options.yaml b/examples/sender/analysis_options.yaml index e86e0b8..cc6f1cb 100644 --- a/examples/sender/analysis_options.yaml +++ b/examples/sender/analysis_options.yaml @@ -1,70 +1,21 @@ +include: package:flutter_lints/flutter.yaml + linter: rules: - always_declare_return_types - - always_require_non_null_named_parameters - - annotate_overrides - - avoid_empty_else - avoid_equals_and_hash_code_on_mutable_classes - avoid_escaping_inner_quotes - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_print - - avoid_relative_lib_imports - - avoid_return_types_on_setters - - avoid_shadowing_type_parameters - avoid_slow_async_io - - avoid_types_as_parameter_names - - avoid_unnecessary_containers - - avoid_unused_constructor_parameters - - camel_case_extensions - - camel_case_types - cancel_subscriptions - close_sinks - - curly_braces_in_flow_control_structures - directives_ordering - - empty_catches - empty_constructor_bodies - - implementation_imports - - library_names - - library_prefixes - - no_duplicate_case_values - - null_closures - omit_local_variable_types - - package_names - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_conditional_assignment - - prefer_contains - - prefer_const_constructors - - prefer_final_fields - prefer_final_locals - - prefer_for_elements_to_map_fromIterable - - prefer_generic_function_type_aliases - - prefer_if_null_operators - - prefer_interpolation_to_compose_strings - - prefer_is_empty - - prefer_is_not_empty - - prefer_iterable_whereType - prefer_single_quotes - - prefer_spread_collections - - prefer_typing_uninitialized_variables - - prefer_void_to_null - - recursive_getters - - slash_for_doc_comments - sort_child_properties_last - sort_constructors_first - sort_pub_dependencies - sort_unnamed_constructors_first - - type_init_formals - unawaited_futures - - unnecessary_const - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_null_in_if_null_operators - - unnecessary_this - - unrelated_type_equality_checks - use_full_hex_values_for_flutter_colors - - use_function_type_syntax_for_parameters - - use_rethrow_when_possible - - valid_regexps - - void_checks diff --git a/examples/sender/pubspec.yaml b/examples/sender/pubspec.yaml index 804c391..937c682 100644 --- a/examples/sender/pubspec.yaml +++ b/examples/sender/pubspec.yaml @@ -10,10 +10,12 @@ environment: dependencies: flutter: sdk: flutter + logging: '^1.2.0' screen_streamer: path: ../../ dev_dependencies: + flutter_lints: '^3.0.1' flutter_test: sdk: flutter diff --git a/lib/src/web_rtc/screen_select_dialog.dart b/lib/src/web_rtc/screen_select_dialog.dart index 56d9803..5a84730 100644 --- a/lib/src/web_rtc/screen_select_dialog.dart +++ b/lib/src/web_rtc/screen_select_dialog.dart @@ -6,6 +6,8 @@ import 'package:logging/logging.dart'; /// Dialog to select what screen or window to stream. class ScreenSelectDialog extends Dialog { + const ScreenSelectDialog({super.key}); + @override Widget build(BuildContext context) { return Material( @@ -56,9 +58,9 @@ class _ScreenSelectContainerState extends State<_ScreenSelectContainer> { @override void dispose() { _timer?.cancel(); - _subscriptions.forEach((element) { + for (var element in _subscriptions) { element.cancel(); - }); + } _subscriptions.clear(); @@ -67,9 +69,9 @@ class _ScreenSelectContainerState extends State<_ScreenSelectContainer> { void _cancel(context) async { _timer?.cancel(); - _subscriptions.forEach((element) { - element.cancel(); - }); + for (var element in _subscriptions) { + await element.cancel(); + } _subscriptions.clear(); if (mounted) { @@ -80,19 +82,19 @@ class _ScreenSelectContainerState extends State<_ScreenSelectContainer> { Future _getSources() async { try { final sources = await desktopCapturer.getSources(types: [_sourceType]); - sources.forEach((element) { + for (var element in sources) { _logger.finer( 'name: ${element.name}, id: ${element.id}, type: ${element.type}', ); - }); + } _timer?.cancel(); _timer = Timer.periodic(const Duration(seconds: 3), (timer) { desktopCapturer.updateSources(types: [_sourceType]); }); _sources.clear(); - sources.forEach((element) { + for (var element in sources) { _sources[element.id] = element; - }); + } _stateSetter?.call(() {}); } catch (e, stack) { _logger.severe( @@ -105,9 +107,9 @@ class _ScreenSelectContainerState extends State<_ScreenSelectContainer> { void _ok(context) async { _timer?.cancel(); - _subscriptions.forEach((element) { - element.cancel(); - }); + for (var element in _subscriptions) { + await element.cancel(); + } Navigator.pop(context, _selectedSource); } @@ -166,13 +168,13 @@ class _ScreenSelectContainerState extends State<_ScreenSelectContainer> { : SourceType.Window; _getSources(); }), - tabs: [ - const Tab( + tabs: const [ + Tab( child: Text( 'Entire Screen', style: TextStyle(color: Colors.black54), )), - const Tab( + Tab( child: Text( 'Window', style: TextStyle(color: Colors.black54), @@ -235,7 +237,7 @@ class _ScreenSelectContainerState extends State<_ScreenSelectContainer> { ), ), ), - Container( + SizedBox( width: double.infinity, child: ButtonBar( children: [ @@ -268,11 +270,10 @@ class _ScreenSelectContainerState extends State<_ScreenSelectContainer> { class _ThumbnailWidget extends StatefulWidget { const _ThumbnailWidget({ - Key? key, required this.onTap, required this.selected, required this.source, - }) : super(key: key); + }); final Function(DesktopCapturerSource) onTap; final bool selected; @@ -298,9 +299,9 @@ class _ThumbnailWidgetState extends State<_ThumbnailWidget> { @override void deactivate() { - _subscriptions.forEach((element) { + for (var element in _subscriptions) { element.cancel(); - }); + } super.deactivate(); } diff --git a/lib/src/web_rtc/screen_sender.dart b/lib/src/web_rtc/screen_sender.dart index 2e4f87f..46d022a 100644 --- a/lib/src/web_rtc/screen_sender.dart +++ b/lib/src/web_rtc/screen_sender.dart @@ -15,7 +15,6 @@ import 'package:screen_streamer/screen_streamer.dart'; import 'package:screen_streamer/src/web_rtc/screen_select_dialog.dart'; import 'package:sdp_transform/sdp_transform.dart'; import 'package:web_socket_channel/web_socket_channel.dart'; -import 'package:web_socket_channel_connect/web_socket_channel_connect.dart'; /// Class to simplify streaming a device's screen or desktop window using /// WebRTC. @@ -49,7 +48,7 @@ class ScreenSender { } else if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) { source = await showDialog( context: context, - builder: (context) => ScreenSelectDialog(), + builder: (context) => const ScreenSelectDialog(), ); } } @@ -59,8 +58,9 @@ class ScreenSender { Completer? completer = Completer(); final future = completer.future; - WebSocketChannel? ws = await connectWebSocket(uri); + WebSocketChannel? ws = WebSocketChannel.connect(uri); try { + await ws.ready; ws.stream.listen((message) async { final map = json.decode(message); diff --git a/lib/src/widget/remote_screen_renderer.dart b/lib/src/widget/remote_screen_renderer.dart index bb75d6d..a2bb59d 100644 --- a/lib/src/widget/remote_screen_renderer.dart +++ b/lib/src/widget/remote_screen_renderer.dart @@ -5,7 +5,7 @@ import 'package:screen_streamer/screen_streamer.dart'; /// Widget that can render a WebRTC stream provided by a remote device. class RemoteScreenRenderer extends StatefulWidget { /// Constructs the renderer with the connected receiver. - RemoteScreenRenderer({ + const RemoteScreenRenderer({ super.key, required this.receiver, }); @@ -13,7 +13,7 @@ class RemoteScreenRenderer extends StatefulWidget { final ScreenReceiver receiver; @override - _RemoteScreenRendererState createState() => _RemoteScreenRendererState(); + State createState() => _RemoteScreenRendererState(); } class _RemoteScreenRendererState extends State { diff --git a/pubspec.yaml b/pubspec.yaml index 3d74cab..ff70ecc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,29 +1,27 @@ name: 'screen_streamer' description: "A library that can stream an android, ios, etc. Flutter application's screen using WebRTC" homepage: 'https://github.com/peiffer-innovations/screen_streamer' -version: '1.0.0+28' +version: '1.0.1' -environment: - sdk: '>=2.19.0 <4.0.0' +environment: + sdk: '>=3.0.0 <4.0.0' -dependencies: +dependencies: device_info_plus: '^9.1.1' - flutter: + flutter: sdk: 'flutter' flutter_background_service: '^5.0.5' flutter_webrtc: '^0.9.47' logging: '^1.2.0' sdp_transform: '^0.3.2' web_socket_channel: '^2.4.0' - web_socket_channel_connect: '^1.0.3' -dev_dependencies: - flutter_test: +dev_dependencies: + flutter_lints: '^3.0.1' + flutter_test: sdk: 'flutter' -flutter: null - -ignore_updates: +ignore_updates: - 'archive' - 'async' - 'boolean_selector' @@ -48,3 +46,6 @@ ignore_updates: - 'typed_data' - 'vector_math' - 'webdriver' + # The "web" package is locked by flutter_test and web_socket_channel 2.4.1 is + # not compatible with Flutter 3.16 due to that. + - 'web_socket_channel'