From 209101796ba186191116ac0de1c79b6cbb8273f5 Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Wed, 20 May 2026 23:48:29 +0200 Subject: [PATCH] refactor: use private named constructor params --- lib/focus/focus_memory_tracker.dart | 4 +--- lib/profiles/active_profile_binder.dart | 4 ++-- lib/profiles/active_profile_provider.dart | 10 +--------- lib/profiles/plex_home_service.dart | 14 +++++--------- lib/providers/download_provider.dart | 17 ++++++----------- lib/providers/offline_watch_provider.dart | 4 +--- lib/services/download_manager_service.dart | 11 ++++------- lib/services/gamepad_service.dart | 5 ++--- lib/services/jellyfin_auth_service.dart | 4 ++-- lib/services/jellyfin_client.dart | 9 ++------- lib/services/jellyfin_trickplay_service.dart | 16 ++++++---------- lib/services/offline_watch_sync_service.dart | 4 +--- lib/services/plex_client.dart | 8 +++----- lib/services/sync_rule_executor.dart | 2 +- .../trackers/tracker_account_store.dart | 8 +------- lib/services/trackers/tracker_coordinator.dart | 2 +- .../services/watch_together_sync_manager.dart | 7 +------ test/widgets/remote_session_dialog_test.dart | 2 +- 18 files changed, 41 insertions(+), 90 deletions(-) diff --git a/lib/focus/focus_memory_tracker.dart b/lib/focus/focus_memory_tracker.dart index c04bb938..88356243 100644 --- a/lib/focus/focus_memory_tracker.dart +++ b/lib/focus/focus_memory_tracker.dart @@ -9,9 +9,7 @@ class FocusMemoryTracker { final String _debugLabelPrefix; String? _lastFocusedKey; - FocusMemoryTracker({VoidCallback? onFocusChanged, String debugLabelPrefix = 'focus'}) - : _onFocusChanged = onFocusChanged, - _debugLabelPrefix = debugLabelPrefix; + FocusMemoryTracker({this._onFocusChanged, this._debugLabelPrefix = 'focus'}); /// Get or create a focus node for the given key FocusNode get(String key, {String? debugLabel}) { diff --git a/lib/profiles/active_profile_binder.dart b/lib/profiles/active_profile_binder.dart index cda441a9..473f41ff 100644 --- a/lib/profiles/active_profile_binder.dart +++ b/lib/profiles/active_profile_binder.dart @@ -39,8 +39,8 @@ class ActiveProfileBinder { required this.multiServerProvider, required this.pinPrompt, this.shouldDeferInitialBind, - PlexAuthService? plexAuth, - }) : _plexAuth = plexAuth; + this._plexAuth, + }); final ActiveProfileProvider activeProfile; final ConnectionRegistry connections; diff --git a/lib/profiles/active_profile_provider.dart b/lib/profiles/active_profile_provider.dart index ccec6c6a..d1e8866f 100644 --- a/lib/profiles/active_profile_provider.dart +++ b/lib/profiles/active_profile_provider.dart @@ -22,15 +22,7 @@ import 'profile_registry.dart'; /// local profiles first, then live home users; if neither matches we fall /// back to the first profile in the merged list. class ActiveProfileProvider extends ChangeNotifier with DisposableChangeNotifierMixin { - ActiveProfileProvider({ - required ProfileRegistry registry, - required PlexHomeService plexHome, - required ConnectionRegistry connections, - StorageService? storage, - }) : _registry = registry, - _plexHome = plexHome, - _connections = connections, - _storage = storage; + ActiveProfileProvider({required this._registry, required this._plexHome, required this._connections, this._storage}); final ProfileRegistry _registry; final PlexHomeService _plexHome; diff --git a/lib/profiles/plex_home_service.dart b/lib/profiles/plex_home_service.dart index 2a778607..30fa634f 100644 --- a/lib/profiles/plex_home_service.dart +++ b/lib/profiles/plex_home_service.dart @@ -21,16 +21,12 @@ import 'profile_connection_registry.dart'; /// background refreshes happen on connection add and via the periodic ticker. class PlexHomeService { PlexHomeService({ - required ConnectionRegistry connections, - required ProfileConnectionRegistry profileConnections, - StorageService? storage, + required this._connections, + required this._profileConnections, + this._storage, Future> Function(String accountToken)? plexHomeUserFetcher, - Duration refreshInterval = const Duration(hours: 1), - }) : _connections = connections, - _profileConnections = profileConnections, - _storage = storage, - _fetchHomeUsers = plexHomeUserFetcher ?? _defaultHomeUserFetcher, - _refreshInterval = refreshInterval; + this._refreshInterval = const Duration(hours: 1), + }) : _fetchHomeUsers = plexHomeUserFetcher ?? _defaultHomeUserFetcher; final ConnectionRegistry _connections; final ProfileConnectionRegistry _profileConnections; diff --git a/lib/providers/download_provider.dart b/lib/providers/download_provider.dart index cf2117d5..74462ccd 100644 --- a/lib/providers/download_provider.dart +++ b/lib/providers/download_provider.dart @@ -87,10 +87,8 @@ class DownloadProvider extends ChangeNotifier with DisposableChangeNotifierMixin OfflineModeSource? _offlineSource; - DownloadProvider({required DownloadManagerService downloadManager, required AppDatabase database}) - : _downloadManager = downloadManager, - _database = database, - _syncRuleExecutor = SyncRuleExecutor(database: database) { + DownloadProvider({required this._downloadManager, required this._database}) + : _syncRuleExecutor = SyncRuleExecutor(database: _database) { // Listen to progress updates from the download manager _progressSubscription = _downloadManager.progressStream.listen(_onProgressUpdate); @@ -112,13 +110,10 @@ class DownloadProvider extends ChangeNotifier with DisposableChangeNotifierMixin /// or path_provider. @visibleForTesting DownloadProvider.forTesting({ - required DownloadManagerService downloadManager, - required AppDatabase database, - String? activeProfileId = 'test-profile', - }) : _downloadManager = downloadManager, - _database = database, - _syncRuleExecutor = SyncRuleExecutor(database: database), - _activeProfileId = activeProfileId { + required this._downloadManager, + required this._database, + this._activeProfileId = 'test-profile', + }) : _syncRuleExecutor = SyncRuleExecutor(database: _database) { _progressSubscription = _downloadManager.progressStream.listen(_onProgressUpdate); _deletionProgressSubscription = _downloadManager.deletionProgressStream.listen(_onDeletionProgressUpdate); _watchStateSubscription = WatchStateNotifier().stream.listen(_onWatchStateChanged); diff --git a/lib/providers/offline_watch_provider.dart b/lib/providers/offline_watch_provider.dart index add7beb2..15533b8a 100644 --- a/lib/providers/offline_watch_provider.dart +++ b/lib/providers/offline_watch_provider.dart @@ -23,9 +23,7 @@ class OfflineWatchProvider extends ChangeNotifier with DisposableChangeNotifierM final OfflineWatchSyncService _syncService; final DownloadProvider _downloadProvider; - OfflineWatchProvider({required OfflineWatchSyncService syncService, required DownloadProvider downloadProvider}) - : _syncService = syncService, - _downloadProvider = downloadProvider { + OfflineWatchProvider({required this._syncService, required this._downloadProvider}) { // Listen to sync service changes to update UI _syncService.addListener(_onSyncServiceChanged); } diff --git a/lib/services/download_manager_service.dart b/lib/services/download_manager_service.dart index b574b4b2..4be3d40b 100644 --- a/lib/services/download_manager_service.dart +++ b/lib/services/download_manager_service.dart @@ -143,14 +143,11 @@ class DownloadManagerService { late final Future recoveryFuture; DownloadManagerService({ - required AppDatabase database, - required DownloadStorageService storageService, + required this._database, + required this._storageService, MediaServerHttpClient? http, - @visibleForTesting bool? downloadsSupportedOverride, - }) : _database = database, - _storageService = storageService, - _downloadsSupportedOverride = downloadsSupportedOverride, - _http = http ?? httpClient; + @visibleForTesting this._downloadsSupportedOverride, + }) : _http = http ?? httpClient; bool get downloadsSupported => _downloadsSupportedOverride ?? platformDownloadsSupported; diff --git a/lib/services/gamepad_service.dart b/lib/services/gamepad_service.dart index ffebd4b7..9d67c099 100644 --- a/lib/services/gamepad_service.dart +++ b/lib/services/gamepad_service.dart @@ -68,10 +68,9 @@ class GamepadDuplicateInputGuard { GamepadDuplicateInputGuard({ DateTime Function()? now, - bool Function()? enabled, + this._enabled, this.suppressionWindow = defaultSuppressionWindow, - }) : _now = now ?? DateTime.now, - _enabled = enabled; + }) : _now = now ?? DateTime.now; bool get _isEnabled => _enabled?.call() ?? true; diff --git a/lib/services/jellyfin_auth_service.dart b/lib/services/jellyfin_auth_service.dart index 913e5753..08b6fff4 100644 --- a/lib/services/jellyfin_auth_service.dart +++ b/lib/services/jellyfin_auth_service.dart @@ -51,8 +51,8 @@ class JellyfinConnectionAuthService implements ConnectionAuthService { required this.clientName, required this.clientVersion, required this.deviceName, - @visibleForTesting http.Client Function()? testHttpClientFactory, - }) : _testHttpClientFactory = testHttpClientFactory; + @visibleForTesting this._testHttpClientFactory, + }); /// App identity sent in the `MediaBrowser` Authorization header. Jellyfin /// uses `Client`/`Device`/`DeviceId`/`Version` to populate the device list diff --git a/lib/services/jellyfin_client.dart b/lib/services/jellyfin_client.dart index 44723987..130bad2e 100644 --- a/lib/services/jellyfin_client.dart +++ b/lib/services/jellyfin_client.dart @@ -86,13 +86,8 @@ class JellyfinClient _JellyfinLiveTvMethods, _JellyfinImageDownloadMethods implements MediaServerClient, ScopedMediaServerClient, GracefullyCloseable { - JellyfinClient._({ - required JellyfinConnection connection, - required MediaServerHttpClient http, - FavoriteChannelsRepository? favoritesRepository, - }) : _connection = connection, - _http = http, - _favoritesRepository = favoritesRepository ?? const SharedPreferencesFavoriteChannelsRepository(); + JellyfinClient._({required this._connection, required this._http, FavoriteChannelsRepository? favoritesRepository}) + : _favoritesRepository = favoritesRepository ?? const SharedPreferencesFavoriteChannelsRepository(); /// Build a fully-initialised [JellyfinClient]. The factory probes /// `/System/Info/Public` to confirm the server is reachable; callers can diff --git a/lib/services/jellyfin_trickplay_service.dart b/lib/services/jellyfin_trickplay_service.dart index bd6776d2..9685d9a4 100644 --- a/lib/services/jellyfin_trickplay_service.dart +++ b/lib/services/jellyfin_trickplay_service.dart @@ -41,16 +41,12 @@ class JellyfinTrickplayService implements ScrubPreviewSource { final Map _providerCache = {}; JellyfinTrickplayService._({ - required JellyfinClient client, - required String itemId, - required String? mediaSourceId, - required TrickplayInfo info, - required TrickplaySheetImageBuilder sheetImageBuilder, - }) : _client = client, - _itemId = itemId, - _mediaSourceId = mediaSourceId, - _info = info, - _sheetImageBuilder = sheetImageBuilder; + required this._client, + required this._itemId, + required this._mediaSourceId, + required this._info, + required this._sheetImageBuilder, + }); /// Picks the best width from [manifest] (smallest >= [targetTooltipWidth], /// largest available otherwise). Returns `null` when [manifest] is empty. diff --git a/lib/services/offline_watch_sync_service.dart b/lib/services/offline_watch_sync_service.dart index 47e9e0bc..48a6daff 100644 --- a/lib/services/offline_watch_sync_service.dart +++ b/lib/services/offline_watch_sync_service.dart @@ -80,9 +80,7 @@ class OfflineWatchSyncService extends ChangeNotifier { /// silently drops local watch progress. static const int maxSyncAttempts = 5; - OfflineWatchSyncService({required AppDatabase database, required MultiServerManager serverManager}) - : _database = database, - _serverManager = serverManager; + OfflineWatchSyncService({required this._database, required this._serverManager}); /// Whether a sync is currently in progress bool get isSyncing => _isSyncing; diff --git a/lib/services/plex_client.dart b/lib/services/plex_client.dart index 8a6cd9db..883b7d0e 100644 --- a/lib/services/plex_client.dart +++ b/lib/services/plex_client.dart @@ -304,14 +304,12 @@ class PlexClient required this.serverId, this.serverName, List? prioritizedEndpoints, - Future Function(String newBaseUrl)? onEndpointChanged, - VoidCallback? onAllEndpointsExhausted, + this._onEndpointChanged, + this._onAllEndpointsExhausted, http.Client? httpClient, }) : _endpointManager = (prioritizedEndpoints != null && prioritizedEndpoints.isNotEmpty) ? EndpointFailoverManager(prioritizedEndpoints) - : null, - _onEndpointChanged = onEndpointChanged, - _onAllEndpointsExhausted = onAllEndpointsExhausted { + : null { LogRedactionManager.registerServer(config.baseUrl, config.token); _http = MediaServerHttpClient( diff --git a/lib/services/sync_rule_executor.dart b/lib/services/sync_rule_executor.dart index 6bfec3d2..864175b9 100644 --- a/lib/services/sync_rule_executor.dart +++ b/lib/services/sync_rule_executor.dart @@ -46,7 +46,7 @@ class SyncRuleExecutor { OfflineModeSource? _offlineSource; - SyncRuleExecutor({required AppDatabase database}) : _database = database; + SyncRuleExecutor({required this._database}); bool get isExecuting => _isExecuting; diff --git a/lib/services/trackers/tracker_account_store.dart b/lib/services/trackers/tracker_account_store.dart index 1e76b820..96321af8 100644 --- a/lib/services/trackers/tracker_account_store.dart +++ b/lib/services/trackers/tracker_account_store.dart @@ -14,13 +14,7 @@ class TrackerAccountStore { final T Function(String raw) _decode; final String Function(T session) _encode; - const TrackerAccountStore({ - required String baseKey, - required T Function(String raw) decode, - required String Function(T session) encode, - }) : _baseKey = baseKey, - _decode = decode, - _encode = encode; + const TrackerAccountStore({required this._baseKey, required this._decode, required this._encode}); String _scopedKey(String userUuid) => userUuid.isEmpty ? _baseKey : 'user_${userUuid}_$_baseKey'; diff --git a/lib/services/trackers/tracker_coordinator.dart b/lib/services/trackers/tracker_coordinator.dart index 0777279f..518277f8 100644 --- a/lib/services/trackers/tracker_coordinator.dart +++ b/lib/services/trackers/tracker_coordinator.dart @@ -432,7 +432,7 @@ class _ManualAnimeProgress { int _count = 0; int? _maxMappedProgress; - _ManualAnimeProgress(this._base, {required bool fallbackToCount}) : _fallbackToCount = fallbackToCount; + _ManualAnimeProgress(this._base, {required this._fallbackToCount}); void add(TrackerContext ctx) { _count++; diff --git a/lib/watch_together/services/watch_together_sync_manager.dart b/lib/watch_together/services/watch_together_sync_manager.dart index 591f806c..73fa33c1 100644 --- a/lib/watch_together/services/watch_together_sync_manager.dart +++ b/lib/watch_together/services/watch_together_sync_manager.dart @@ -87,12 +87,7 @@ class WatchTogetherSyncManager { SyncStateCallback? onSyncStateChanged; DeferredPlayCallback? onDeferredPlayChanged; - WatchTogetherSyncManager({ - required WatchTogetherPeerService peerService, - required WatchSession session, - required this.displayName, - }) : _peerService = peerService, - _session = session; + WatchTogetherSyncManager({required this._peerService, required this._session, required this.displayName}); /// Update the session (e.g., when control mode changes) void updateSession(WatchSession session) { diff --git a/test/widgets/remote_session_dialog_test.dart b/test/widgets/remote_session_dialog_test.dart index 60ff3531..5d90dde6 100644 --- a/test/widgets/remote_session_dialog_test.dart +++ b/test/widgets/remote_session_dialog_test.dart @@ -77,7 +77,7 @@ void main() { } class _FakeCompanionRemoteProvider extends CompanionRemoteProvider { - _FakeCompanionRemoteProvider({bool isHostServerRunning = false}) : _isHostServerRunning = isHostServerRunning; + _FakeCompanionRemoteProvider({this._isHostServerRunning = false}); bool _isHostServerRunning; int startCount = 0;