From 5056f43f1d5ac01d9ee7dd48f746aa066b41f4dd Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Fri, 8 Sep 2023 10:28:10 +0200 Subject: [PATCH 1/5] feat(app,dynamite,neon,neon_files,neon_news,neon_notes,neon_notifications,neon_lints,nextcloud): enable strict-raw-types Signed-off-by: Nikolas Rimikis --- .../app/integration_test/screenshot_test.dart | 10 ++++----- packages/app/lib/main.dart | 2 +- .../dynamite/lib/src/builder/client.dart | 2 +- packages/neon/neon/lib/neon.dart | 2 +- packages/neon/neon/lib/src/app.dart | 12 +++++----- packages/neon/neon/lib/src/bloc/bloc.dart | 6 ++--- packages/neon/neon/lib/src/blocs/apps.dart | 10 ++++----- .../neon/neon/lib/src/blocs/capabilities.dart | 2 +- .../neon/neon/lib/src/blocs/first_launch.dart | 4 ++-- .../lib/src/blocs/login_check_account.dart | 2 +- .../src/blocs/login_check_server_status.dart | 2 +- .../neon/neon/lib/src/blocs/login_flow.dart | 2 +- .../neon/neon/lib/src/blocs/next_push.dart | 4 ++-- .../lib/src/blocs/push_notifications.dart | 8 +++---- .../neon/lib/src/blocs/unified_search.dart | 8 +++---- .../neon/neon/lib/src/blocs/user_details.dart | 2 +- .../neon/lib/src/blocs/user_statuses.dart | 4 ++-- .../lib/src/models/app_implementation.dart | 2 +- packages/neon/neon/lib/src/pages/home.dart | 6 ++--- .../neon/lib/src/pages/route_not_found.dart | 2 +- .../neon/neon/lib/src/platform/platform.dart | 4 ++-- packages/neon/neon/lib/src/router.dart | 2 +- .../settings/models/options_collection.dart | 4 ++-- .../neon/lib/src/settings/models/storage.dart | 18 +++++++-------- .../src/settings/widgets/settings_tile.dart | 2 +- .../neon/lib/src/utils/account_options.dart | 2 +- .../neon/lib/src/utils/global_options.dart | 4 ++-- .../neon/lib/src/utils/global_popups.dart | 2 +- .../neon/neon/lib/src/utils/push_utils.dart | 2 +- .../neon/lib/src/utils/request_manager.dart | 12 +++++----- .../neon/neon/lib/src/widgets/app_bar.dart | 4 ++-- .../neon/neon/lib/src/widgets/list_view.dart | 2 +- packages/neon/neon/test/option_test.dart | 4 ++-- .../neon/test/options_collection_test.dart | 4 ++-- .../neon/neon_files/lib/blocs/browser.dart | 2 +- packages/neon/neon_files/lib/blocs/files.dart | 4 ++-- .../neon_files/lib/dialogs/choose_create.dart | 4 ++-- packages/neon/neon_files/lib/neon_files.dart | 2 +- packages/neon/neon_files/lib/utils/task.dart | 4 ++-- .../neon/neon_news/lib/blocs/article.dart | 4 ++-- .../neon/neon_news/lib/blocs/articles.dart | 4 ++-- packages/neon/neon_news/lib/blocs/news.dart | 4 ++-- packages/neon/neon_news/lib/neon_news.dart | 2 +- .../neon/neon_news/lib/pages/article.dart | 2 +- packages/neon/neon_notes/lib/blocs/note.dart | 2 +- packages/neon/neon_notes/lib/blocs/notes.dart | 4 ++-- packages/neon/neon_notes/lib/neon_notes.dart | 2 +- .../lib/blocs/notifications.dart | 2 +- .../lib/neon_notifications.dart | 2 +- packages/neon_lints/lib/src/base.yaml | 1 + packages/neon_lints/lint_maker.yaml | 1 + .../nextcloud/lib/src/api/news.openapi.dart | 22 +++++++++---------- packages/nextcloud/lib/src/webdav/client.dart | 2 +- packages/nextcloud/test/helper.dart | 2 +- .../nextcloud/test/notifications_test.dart | 2 +- packages/nextcloud/test/settings_test.dart | 4 ++-- packages/sort_box/lib/sort_box.dart | 2 +- 57 files changed, 120 insertions(+), 118 deletions(-) diff --git a/packages/app/integration_test/screenshot_test.dart b/packages/app/integration_test/screenshot_test.dart index def82780..5b9c4647 100644 --- a/packages/app/integration_test/screenshot_test.dart +++ b/packages/app/integration_test/screenshot_test.dart @@ -14,7 +14,7 @@ import 'package:neon/settings.dart'; import 'package:neon_files/widgets/actions.dart'; import 'package:shared_preferences/shared_preferences.dart'; -Future runTestApp( +Future runTestApp( final WidgetTester tester, final IntegrationTestWidgetsFlutterBinding binding, { final Account? account, @@ -30,18 +30,18 @@ Future runTestApp( await tester.pumpAndSettle(); } -Future openDrawer(final WidgetTester tester) async { +Future openDrawer(final WidgetTester tester) async { await tester.tap(find.byTooltip('Open navigation menu')); await tester.pumpAndSettle(); } -Future switchPage(final WidgetTester tester, final String name) async { +Future switchPage(final WidgetTester tester, final String name) async { await openDrawer(tester); await tester.tap(find.text(name).last); await tester.pumpAndSettle(); } -Future prepareScreenshot(final WidgetTester tester, final IntegrationTestWidgetsFlutterBinding binding) async { +Future prepareScreenshot(final WidgetTester tester, final IntegrationTestWidgetsFlutterBinding binding) async { await binding.convertFlutterSurfaceToImage(); await tester.pumpAndSettle(); } @@ -63,7 +63,7 @@ Future getAccount(final String username) async { ); } -Future main() async { +Future main() async { // The screenshots are pretty annoying on Android. See https://github.com/flutter/flutter/issues/92381 assert(Platform.isAndroid, 'Screenshots need to be taken on Android'); diff --git a/packages/app/lib/main.dart b/packages/app/lib/main.dart index 62c13ad3..c732b8ba 100644 --- a/packages/app/lib/main.dart +++ b/packages/app/lib/main.dart @@ -2,7 +2,7 @@ import 'package:app/apps.dart'; import 'package:app/branding.dart'; import 'package:neon/neon.dart'; -Future main() async { +Future main() async { await runNeon( appImplementations: appImplementations, theme: neonTheme, diff --git a/packages/dynamite/dynamite/lib/src/builder/client.dart b/packages/dynamite/dynamite/lib/src/builder/client.dart index 636fc18e..e941634b 100644 --- a/packages/dynamite/dynamite/lib/src/builder/client.dart +++ b/packages/dynamite/dynamite/lib/src/builder/client.dart @@ -604,7 +604,7 @@ final _response = await ${isRootClient ? 'this' : '_rootClient'}.doRequest( b.returns = refer('Future<$dataType>'); code.write('return $dataValue;'); } else { - b.returns = refer('Future'); + b.returns = refer('Future'); code.write('return;'); } diff --git a/packages/neon/neon/lib/neon.dart b/packages/neon/neon/lib/neon.dart index 2df80d53..ba72a974 100644 --- a/packages/neon/neon/lib/neon.dart +++ b/packages/neon/neon/lib/neon.dart @@ -18,7 +18,7 @@ import 'package:neon/src/utils/user_agent.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:provider/provider.dart'; -Future runNeon({ +Future runNeon({ required final Iterable appImplementations, required final NeonTheme theme, @visibleForTesting final WidgetsBinding? bindingOverride, diff --git a/packages/neon/neon/lib/src/app.dart b/packages/neon/neon/lib/src/app.dart index 29e8a5f7..e06ed853 100644 --- a/packages/neon/neon/lib/src/app.dart +++ b/packages/neon/neon/lib/src/app.dart @@ -196,7 +196,7 @@ class _NeonAppState extends State with WidgetsBindingObserver, tray.Tra } @override - Future onWindowClose() async { + Future onWindowClose() async { if (_globalOptions.startupMinimizeInsteadOfExit.value) { await _saveAndMinimizeWindow(); } else { @@ -205,11 +205,11 @@ class _NeonAppState extends State with WidgetsBindingObserver, tray.Tra } @override - Future onWindowMinimize() async { + Future onWindowMinimize() async { await _saveAndMinimizeWindow(); } - Future _handleShortcut(final String shortcutType) async { + Future _handleShortcut(final String shortcutType) async { if (shortcutType == 'show_hide') { if (NeonPlatform.instance.canUseWindowManager) { if (await windowManager.isVisible()) { @@ -231,13 +231,13 @@ class _NeonAppState extends State with WidgetsBindingObserver, tray.Tra } } - Future _openAppFromExternal(final Account account, final String id) async { + Future _openAppFromExternal(final Account account, final String id) async { await _accountsBloc.getAppsBlocFor(account).setActiveApp(id); _navigatorKey.currentState!.popUntil((final route) => route.settings.name == 'home'); await _showAndRestoreWindow(); } - Future _saveAndMinimizeWindow() async { + Future _saveAndMinimizeWindow() async { _lastBounds = await windowManager.getBounds(); if (_globalOptions.systemTrayEnabled.value && _globalOptions.systemTrayHideToTrayWhenMinimized.value) { await windowManager.hide(); @@ -246,7 +246,7 @@ class _NeonAppState extends State with WidgetsBindingObserver, tray.Tra } } - Future _showAndRestoreWindow() async { + Future _showAndRestoreWindow() async { if (!NeonPlatform.instance.canUseWindowManager) { return; } diff --git a/packages/neon/neon/lib/src/bloc/bloc.dart b/packages/neon/neon/lib/src/bloc/bloc.dart index 96263e4c..d1907585 100644 --- a/packages/neon/neon/lib/src/bloc/bloc.dart +++ b/packages/neon/neon/lib/src/bloc/bloc.dart @@ -17,7 +17,7 @@ abstract class InteractiveBloc extends Bloc { final _errorsStreamController = StreamController(); late Stream errors = _errorsStreamController.stream.asBroadcastStream(); - Future refresh(); + Future refresh(); void addError(final Object error) { _errorsStreamController.add(error); @@ -25,9 +25,9 @@ abstract class InteractiveBloc extends Bloc { // ignore: avoid_void_async void wrapAction( - final Future Function() call, { + final Future Function() call, { final bool disableTimeout = false, - final Future Function()? refresh, + final Future Function()? refresh, }) async { try { if (disableTimeout) { diff --git a/packages/neon/neon/lib/src/blocs/apps.dart b/packages/neon/neon/lib/src/blocs/apps.dart index bf7cd847..e8c8b201 100644 --- a/packages/neon/neon/lib/src/blocs/apps.dart +++ b/packages/neon/neon/lib/src/blocs/apps.dart @@ -33,7 +33,7 @@ abstract class AppsBlocStates { BehaviorSubject get activeApp; - BehaviorSubject get openNotifications; + BehaviorSubject get openNotifications; BehaviorSubject?> get appVersions; } @@ -182,13 +182,13 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates BehaviorSubject>(); @override - BehaviorSubject openNotifications = BehaviorSubject(); + BehaviorSubject openNotifications = BehaviorSubject(); @override BehaviorSubject?> appVersions = BehaviorSubject(); @override - Future refresh() async { + Future refresh() async { await RequestManager.instance .wrapNextcloud, CoreNavigationGetAppsNavigationResponseApplicationJson>( _account.id, @@ -200,7 +200,7 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates } @override - Future setActiveApp(final String appID, {final bool skipAlreadySet = false}) async { + Future setActiveApp(final String appID, {final bool skipAlreadySet = false}) async { if (appID == AppIDs.notifications) { openNotifications.add(null); return; @@ -220,6 +220,6 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates T getAppBloc(final AppImplementation appImplementation) => appImplementation.getBloc(_account); - List get appBlocProviders => + List> get appBlocProviders => _allAppImplementations.map((final appImplementation) => appImplementation.blocProvider).toList(); } diff --git a/packages/neon/neon/lib/src/blocs/capabilities.dart b/packages/neon/neon/lib/src/blocs/capabilities.dart index e77eeeb0..bc6a2d43 100644 --- a/packages/neon/neon/lib/src/blocs/capabilities.dart +++ b/packages/neon/neon/lib/src/blocs/capabilities.dart @@ -35,7 +35,7 @@ class CapabilitiesBloc extends InteractiveBloc implements CapabilitiesBlocEvents BehaviorSubject>(); @override - Future refresh() async { + Future refresh() async { await RequestManager.instance.wrapNextcloud( _account.id, diff --git a/packages/neon/neon/lib/src/blocs/first_launch.dart b/packages/neon/neon/lib/src/blocs/first_launch.dart index 056e9378..2a0e9341 100644 --- a/packages/neon/neon/lib/src/blocs/first_launch.dart +++ b/packages/neon/neon/lib/src/blocs/first_launch.dart @@ -8,7 +8,7 @@ import 'package:rxdart/rxdart.dart'; abstract class FirstLaunchBlocEvents {} abstract class FirstLaunchBlocStates { - BehaviorSubject get onFirstLaunch; + BehaviorSubject get onFirstLaunch; } @immutable @@ -31,5 +31,5 @@ class FirstLaunchBloc extends Bloc implements FirstLaunchBlocEvents, FirstLaunch } @override - final BehaviorSubject onFirstLaunch = BehaviorSubject(); + final BehaviorSubject onFirstLaunch = BehaviorSubject(); } diff --git a/packages/neon/neon/lib/src/blocs/login_check_account.dart b/packages/neon/neon/lib/src/blocs/login_check_account.dart index f7b97561..bffccfeb 100644 --- a/packages/neon/neon/lib/src/blocs/login_check_account.dart +++ b/packages/neon/neon/lib/src/blocs/login_check_account.dart @@ -40,7 +40,7 @@ class LoginCheckAccountBloc extends InteractiveBloc BehaviorSubject> state = BehaviorSubject(); @override - Future refresh() async { + Future refresh() async { state.add(Result.loading()); try { diff --git a/packages/neon/neon/lib/src/blocs/login_check_server_status.dart b/packages/neon/neon/lib/src/blocs/login_check_server_status.dart index a92529f1..a31b7922 100644 --- a/packages/neon/neon/lib/src/blocs/login_check_server_status.dart +++ b/packages/neon/neon/lib/src/blocs/login_check_server_status.dart @@ -33,7 +33,7 @@ class LoginCheckServerStatusBloc extends InteractiveBloc BehaviorSubject> state = BehaviorSubject(); @override - Future refresh() async { + Future refresh() async { state.add(Result.loading()); try { diff --git a/packages/neon/neon/lib/src/blocs/login_flow.dart b/packages/neon/neon/lib/src/blocs/login_flow.dart index ee6cfc10..291907af 100644 --- a/packages/neon/neon/lib/src/blocs/login_flow.dart +++ b/packages/neon/neon/lib/src/blocs/login_flow.dart @@ -45,7 +45,7 @@ class LoginFlowBloc extends InteractiveBloc implements LoginFlowBlocEvents, Logi late Stream result = _resultController.stream.asBroadcastStream(); @override - Future refresh() async { + Future refresh() async { try { init.add(Result.loading()); diff --git a/packages/neon/neon/lib/src/blocs/next_push.dart b/packages/neon/neon/lib/src/blocs/next_push.dart index c1ba9bc3..4419d495 100644 --- a/packages/neon/neon/lib/src/blocs/next_push.dart +++ b/packages/neon/neon/lib/src/blocs/next_push.dart @@ -11,7 +11,7 @@ import 'package:rxdart/rxdart.dart'; abstract class NextPushBlocEvents {} abstract class NextPushBlocStates { - BehaviorSubject get onNextPushSupported; + BehaviorSubject get onNextPushSupported; } @internal @@ -78,5 +78,5 @@ class NextPushBloc extends Bloc implements NextPushBlocEvents, NextPushBlocState } @override - BehaviorSubject onNextPushSupported = BehaviorSubject(); + BehaviorSubject onNextPushSupported = BehaviorSubject(); } diff --git a/packages/neon/neon/lib/src/blocs/push_notifications.dart b/packages/neon/neon/lib/src/blocs/push_notifications.dart index a701ade7..2ab5e109 100644 --- a/packages/neon/neon/lib/src/blocs/push_notifications.dart +++ b/packages/neon/neon/lib/src/blocs/push_notifications.dart @@ -40,7 +40,7 @@ class PushNotificationsBloc extends Bloc implements PushNotificationsBlocEvents, final GlobalOptions _globalOptions; final _notificationsController = StreamController(); - StreamSubscription? _accountsListener; + StreamSubscription>? _accountsListener; @override void dispose() { @@ -66,7 +66,7 @@ class PushNotificationsBloc extends Bloc implements PushNotificationsBlocEvents, } } - Future _setupUnifiedPush() async { + Future _setupUnifiedPush() async { // We just use a single RSA keypair for all accounts final keypair = await PushUtils.loadRSAKeypair(); @@ -118,7 +118,7 @@ class PushNotificationsBloc extends Bloc implements PushNotificationsBlocEvents, } } - Future _unregisterUnifiedPushInstances(final List accounts) async { + Future _unregisterUnifiedPushInstances(final List accounts) async { for (final account in accounts) { try { await account.client.notifications.push.removeDevice(); @@ -130,7 +130,7 @@ class PushNotificationsBloc extends Bloc implements PushNotificationsBlocEvents, } } - Future _registerUnifiedPushInstances(final List accounts) async { + Future _registerUnifiedPushInstances(final List accounts) async { // Notifications will only work on accounts with app password for (final account in accounts.where((final a) => a.password != null)) { await UnifiedPush.registerApp(account.id); diff --git a/packages/neon/neon/lib/src/blocs/unified_search.dart b/packages/neon/neon/lib/src/blocs/unified_search.dart index 2a998601..6c67da69 100644 --- a/packages/neon/neon/lib/src/blocs/unified_search.dart +++ b/packages/neon/neon/lib/src/blocs/unified_search.dart @@ -56,12 +56,12 @@ class UnifiedSearchBloc extends InteractiveBloc implements UnifiedSearchBlocEven } @override - Future refresh() async { + Future refresh() async { await _search(); } @override - Future search(final String term) async { + Future search(final String term) async { _term = term.trim(); await _search(); } @@ -78,7 +78,7 @@ class UnifiedSearchBloc extends InteractiveBloc implements UnifiedSearchBlocEven _term = ''; } - Future _search() async { + Future _search() async { if (_term.isEmpty) { results.add(Result.success(null)); return; @@ -108,7 +108,7 @@ class UnifiedSearchBloc extends InteractiveBloc implements UnifiedSearchBlocEven } } - Future _searchProvider(final CoreUnifiedSearchProvider provider) async { + Future _searchProvider(final CoreUnifiedSearchProvider provider) async { _updateResults(provider, Result.loading()); try { final response = await _account.client.core.unifiedSearch.search( diff --git a/packages/neon/neon/lib/src/blocs/user_details.dart b/packages/neon/neon/lib/src/blocs/user_details.dart index 6df57f3c..8a528316 100644 --- a/packages/neon/neon/lib/src/blocs/user_details.dart +++ b/packages/neon/neon/lib/src/blocs/user_details.dart @@ -35,7 +35,7 @@ class UserDetailsBloc extends InteractiveBloc implements UserDetailsBlocEvents, BehaviorSubject>(); @override - Future refresh() async { + Future refresh() async { await RequestManager.instance .wrapNextcloud( _account.id, diff --git a/packages/neon/neon/lib/src/blocs/user_statuses.dart b/packages/neon/neon/lib/src/blocs/user_statuses.dart index 03f5e0b7..96213c1d 100644 --- a/packages/neon/neon/lib/src/blocs/user_statuses.dart +++ b/packages/neon/neon/lib/src/blocs/user_statuses.dart @@ -43,14 +43,14 @@ class UserStatusesBloc extends InteractiveBloc implements UserStatusesBlocEvents BehaviorSubject>>(); @override - Future refresh() async { + Future refresh() async { for (final username in _statuses.keys) { await load(username, force: true); } } @override - Future load(final String username, {final bool force = false}) async { + Future load(final String username, {final bool force = false}) async { if (!force && _statuses.containsKey(username)) { return; } diff --git a/packages/neon/neon/lib/src/models/app_implementation.dart b/packages/neon/neon/lib/src/models/app_implementation.dart index 4ea33c1a..a36936cd 100644 --- a/packages/neon/neon/lib/src/models/app_implementation.dart +++ b/packages/neon/neon/lib/src/models/app_implementation.dart @@ -18,7 +18,7 @@ abstract class AppImplementation AppImplementation(); String get id; - LocalizationsDelegate get localizationsDelegate; + LocalizationsDelegate get localizationsDelegate; List get supportedLocales; String nameFromLocalization(final AppLocalizations localizations) => localizations.appImplementationName(id); diff --git a/packages/neon/neon/lib/src/pages/home.dart b/packages/neon/neon/lib/src/pages/home.dart index a76f932a..acec5a12 100644 --- a/packages/neon/neon/lib/src/pages/home.dart +++ b/packages/neon/neon/lib/src/pages/home.dart @@ -32,7 +32,7 @@ class _HomePageState extends State { late GlobalOptions _globalOptions; late AccountsBloc _accountsBloc; late AppsBloc _appsBloc; - late StreamSubscription _versionCheckSubscription; + late StreamSubscription?> _versionCheckSubscription; @override void initState() { @@ -76,7 +76,7 @@ class _HomePageState extends State { super.dispose(); } - Future _checkMaintenanceMode() async { + Future _checkMaintenanceMode() async { try { final status = await _account.client.core.getStatus(); if (status.maintenance && mounted) { @@ -93,7 +93,7 @@ class _HomePageState extends State { } } - Future _showProblem(final String title) async { + Future _showProblem(final String title) async { final colorScheme = Theme.of(context).colorScheme; await showDialog( diff --git a/packages/neon/neon/lib/src/pages/route_not_found.dart b/packages/neon/neon/lib/src/pages/route_not_found.dart index 884172f2..1cc133af 100644 --- a/packages/neon/neon/lib/src/pages/route_not_found.dart +++ b/packages/neon/neon/lib/src/pages/route_not_found.dart @@ -27,7 +27,7 @@ class _RouteNotFoundPageState extends State { unawaited(_checkLaunchable()); } - Future _checkLaunchable() async { + Future _checkLaunchable() async { final accountsBloc = Provider.of(context, listen: false); if (!accountsBloc.hasAccounts) { return; diff --git a/packages/neon/neon/lib/src/platform/platform.dart b/packages/neon/neon/lib/src/platform/platform.dart index 0bedd437..8c541890 100644 --- a/packages/neon/neon/lib/src/platform/platform.dart +++ b/packages/neon/neon/lib/src/platform/platform.dart @@ -16,7 +16,7 @@ abstract interface class NeonPlatform { /// Infers and configures the platform automatically. /// /// Required to be called before accessing [NeonPlatform.instance]. - static Future setup() async { + static Future setup() async { if (Platform.isAndroid) { _platform = const AndroidNeonPlatform(); } else if (Platform.isLinux) { @@ -55,5 +55,5 @@ abstract interface class NeonPlatform { FutureOr get userAccessibleAppDataPath; - FutureOr init(); + FutureOr init(); } diff --git a/packages/neon/neon/lib/src/router.dart b/packages/neon/neon/lib/src/router.dart index 38290042..6e666b70 100644 --- a/packages/neon/neon/lib/src/router.dart +++ b/packages/neon/neon/lib/src/router.dart @@ -62,7 +62,7 @@ class AppRouter extends GoRouter { routes: $appRoutes, ); - static Page _buildErrorPage(final BuildContext context, final GoRouterState state) => MaterialPage( + static Page _buildErrorPage(final BuildContext context, final GoRouterState state) => MaterialPage( child: RouteNotFoundPage( uri: state.uri, ), diff --git a/packages/neon/neon/lib/src/settings/models/options_collection.dart b/packages/neon/neon/lib/src/settings/models/options_collection.dart index 59e5b4a6..a2e5c310 100644 --- a/packages/neon/neon/lib/src/settings/models/options_collection.dart +++ b/packages/neon/neon/lib/src/settings/models/options_collection.dart @@ -14,7 +14,7 @@ abstract class OptionsCollection implements Exportable { /// Collection of options. @protected - Iterable