From 19343999783818cf5c5855a9ea2966b39fb0e430 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Wed, 31 Aug 2022 07:58:48 +0200 Subject: [PATCH] Cleanup linting issues --- packages/file_icons/analysis_options.yaml | 4 --- packages/neon/analysis_options.yaml | 4 --- .../integration_test/screenshot_test.dart | 26 +++++++------- packages/neon/lib/app.dart | 4 ++- packages/neon/lib/src/apps/files/app.dart | 10 +++--- .../lib/src/apps/files/blocs/browser.dart | 6 ++-- .../neon/lib/src/apps/files/blocs/files.dart | 6 ++-- .../src/apps/files/dialogs/choose_folder.dart | 2 +- .../lib/src/apps/files/pages/details.dart | 2 +- .../neon/lib/src/apps/files/pages/main.dart | 2 +- .../src/apps/files/widgets/file_preview.dart | 2 +- packages/neon/lib/src/apps/news/app.dart | 10 +++--- .../lib/src/apps/news/blocs/articles.dart | 8 ++--- .../neon/lib/src/apps/news/blocs/news.dart | 8 ++--- .../lib/src/apps/news/dialogs/add_feed.dart | 16 +++++---- .../neon/lib/src/apps/news/pages/article.dart | 4 +-- packages/neon/lib/src/apps/notes/app.dart | 10 +++--- .../neon/lib/src/apps/notes/blocs/notes.dart | 4 +-- .../neon/lib/src/apps/notes/pages/note.dart | 8 ++--- .../neon/lib/src/apps/notifications/app.dart | 10 +++--- .../notifications/blocs/notifications.dart | 6 ++-- .../src/apps/notifications/pages/main.dart | 5 +-- packages/neon/lib/src/blocs/accounts.dart | 19 ++++++----- packages/neon/lib/src/blocs/apps.dart | 34 +++++++++++-------- packages/neon/lib/src/blocs/capabilities.dart | 4 ++- packages/neon/lib/src/blocs/login.dart | 8 ++--- .../lib/src/blocs/push_notifications.dart | 6 ++-- packages/neon/lib/src/blocs/user_details.dart | 4 ++- packages/neon/lib/src/blocs/user_status.dart | 4 +-- packages/neon/lib/src/models/account.dart | 7 ++-- .../src/models/nextcloud_notification.dart | 2 +- packages/neon/lib/src/neon.dart | 1 - packages/neon/lib/src/pages/home/home.dart | 10 +++--- .../neon/lib/src/pages/settings/settings.dart | 4 +-- .../lib/src/utils/app_implementation.dart | 14 ++++---- .../lib/src/utils/confirmation_dialog.dart | 4 +-- .../neon/lib/src/utils/global_options.dart | 4 +-- packages/neon/lib/src/utils/push_utils.dart | 11 +++--- packages/neon/lib/src/utils/theme.dart | 4 +-- .../neon/lib/src/widgets/image_wrapper.dart | 2 +- packages/nextcloud/analysis_options.yaml | 4 --- .../lib/src/clients/notifications.dart | 2 +- .../analysis_options.yaml | 4 --- .../lib/nextcloud_push_proxy.dart | 6 ++-- packages/settings/analysis_options.yaml | 4 --- packages/settings/lib/settings.dart | 2 ++ packages/settings/lib/src/options/option.dart | 4 +-- .../lib/src/options/select_option.dart | 18 +++++----- packages/spec_templates/analysis_options.yaml | 4 --- 49 files changed, 172 insertions(+), 175 deletions(-) diff --git a/packages/file_icons/analysis_options.yaml b/packages/file_icons/analysis_options.yaml index 0cc523ce..0ed2fb9f 100644 --- a/packages/file_icons/analysis_options.yaml +++ b/packages/file_icons/analysis_options.yaml @@ -1,5 +1 @@ include: package:nit_picking/dart.yaml - -linter: - rules: - prefer_final_parameters: false # Disabled until super.X is no longer complained about in constructors diff --git a/packages/neon/analysis_options.yaml b/packages/neon/analysis_options.yaml index 9184e2e9..f7732dad 100644 --- a/packages/neon/analysis_options.yaml +++ b/packages/neon/analysis_options.yaml @@ -1,9 +1,5 @@ include: package:nit_picking/flutter.yaml -linter: - rules: - prefer_final_parameters: false # Disabled until super.X is no longer complained about in constructors - analyzer: exclude: - lib/src/l10n/** diff --git a/packages/neon/integration_test/screenshot_test.dart b/packages/neon/integration_test/screenshot_test.dart index cea7fa29..0fd659da 100644 --- a/packages/neon/integration_test/screenshot_test.dart +++ b/packages/neon/integration_test/screenshot_test.dart @@ -34,7 +34,7 @@ class MemorySharedPreferences implements SharedPreferences { Future reload() async {} @override - Future remove(String key) async { + Future remove(final String key) async { _data.remove(key); return true; } @@ -43,52 +43,52 @@ class MemorySharedPreferences implements SharedPreferences { Set getKeys() => _data.keys.toSet(); @override - bool containsKey(String key) => _data.keys.contains(key); + bool containsKey(final String key) => _data.keys.contains(key); @override - Object? get(String key) => _data[key]; + Object? get(final String key) => _data[key]; @override - bool? getBool(String key) => _data[key] as bool?; + bool? getBool(final String key) => _data[key] as bool?; @override - double? getDouble(String key) => _data[key] as double?; + double? getDouble(final String key) => _data[key] as double?; @override - int? getInt(String key) => _data[key] as int?; + int? getInt(final String key) => _data[key] as int?; @override - String? getString(String key) => _data[key] as String?; + String? getString(final String key) => _data[key] as String?; @override - List? getStringList(String key) => (_data[key] as List).cast(); + List? getStringList(final String key) => (_data[key] as List).cast(); @override - Future setBool(String key, bool value) async { + Future setBool(final String key, final bool value) async { _data[key] = value; return true; } @override - Future setDouble(String key, double value) async { + Future setDouble(final String key, final double value) async { _data[key] = value; return true; } @override - Future setInt(String key, int value) async { + Future setInt(final String key, final int value) async { _data[key] = value; return true; } @override - Future setString(String key, String value) async { + Future setString(final String key, final String value) async { _data[key] = value; return true; } @override - Future setStringList(String key, List value) async { + Future setStringList(final String key, final List value) async { _data[key] = value; return true; } diff --git a/packages/neon/lib/app.dart b/packages/neon/lib/app.dart index 1b4876dd..1546d2be 100644 --- a/packages/neon/lib/app.dart +++ b/packages/neon/lib/app.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter_native_splash/flutter_native_splash.dart'; import 'package:neon/l10n/localizations.dart'; @@ -84,7 +86,7 @@ class _NeonAppState extends State with WidgetsBindingObserver { @override void dispose() { WidgetsBinding.instance.removeObserver(this); - _platformBrightness.close(); + unawaited(_platformBrightness.close()); super.dispose(); } diff --git a/packages/neon/lib/src/apps/files/app.dart b/packages/neon/lib/src/apps/files/app.dart index 85f4ea32..480c3eb1 100644 --- a/packages/neon/lib/src/apps/files/app.dart +++ b/packages/neon/lib/src/apps/files/app.dart @@ -46,13 +46,13 @@ class FilesApp extends AppImplementation { String id = 'files'; @override - String nameFromLocalization(AppLocalizations localizations) => localizations.filesName; + String nameFromLocalization(final AppLocalizations localizations) => localizations.filesName; @override - FilesAppSpecificOptions buildOptions(Storage storage) => FilesAppSpecificOptions(storage); + FilesAppSpecificOptions buildOptions(final Storage storage) => FilesAppSpecificOptions(storage); @override - FilesBloc buildBloc(NextcloudClient client) => FilesBloc( + FilesBloc buildBloc(final NextcloudClient client) => FilesBloc( options, requestManager, client, @@ -60,10 +60,10 @@ class FilesApp extends AppImplementation { ); @override - Widget buildPage(BuildContext context, AppsBloc appsBloc) => FilesMainPage( + Widget buildPage(final BuildContext context, final AppsBloc appsBloc) => FilesMainPage( bloc: appsBloc.getAppBloc(this), ); @override - BehaviorSubject? getUnreadCounter(AppsBloc appsBloc) => null; + BehaviorSubject? getUnreadCounter(final AppsBloc appsBloc) => null; } diff --git a/packages/neon/lib/src/apps/files/blocs/browser.dart b/packages/neon/lib/src/apps/files/blocs/browser.dart index 6b6d4379..6351c4a0 100644 --- a/packages/neon/lib/src/apps/files/blocs/browser.dart +++ b/packages/neon/lib/src/apps/files/blocs/browser.dart @@ -86,9 +86,9 @@ class FilesBrowserBloc extends $FilesBrowserBloc { @override void dispose() { - _filesSubject.close(); - _pathSubject.close(); - _errorsStreamController.close(); + unawaited(_filesSubject.close()); + unawaited(_pathSubject.close()); + unawaited(_errorsStreamController.close()); super.dispose(); } diff --git a/packages/neon/lib/src/apps/files/blocs/files.dart b/packages/neon/lib/src/apps/files/blocs/files.dart index d8eb0cf2..c643a7c4 100644 --- a/packages/neon/lib/src/apps/files/blocs/files.dart +++ b/packages/neon/lib/src/apps/files/blocs/files.dart @@ -226,9 +226,9 @@ class FilesBloc extends $FilesBloc { void dispose() { _uploadQueue.dispose(); _downloadQueue.dispose(); - _uploadTasksSubject.close(); - _downloadTasksSubject.close(); - _errorsStreamController.close(); + unawaited(_uploadTasksSubject.close()); + unawaited(_downloadTasksSubject.close()); + unawaited(_errorsStreamController.close()); super.dispose(); } diff --git a/packages/neon/lib/src/apps/files/dialogs/choose_folder.dart b/packages/neon/lib/src/apps/files/dialogs/choose_folder.dart index 6302c5ee..17c42f20 100644 --- a/packages/neon/lib/src/apps/files/dialogs/choose_folder.dart +++ b/packages/neon/lib/src/apps/files/dialogs/choose_folder.dart @@ -14,7 +14,7 @@ class FilesChooseFolderDialog extends StatelessWidget { final List originalPath; @override - Widget build(BuildContext context) => AlertDialog( + Widget build(final BuildContext context) => AlertDialog( title: Text(AppLocalizations.of(context).filesChooseFolder), contentPadding: EdgeInsets.zero, content: SizedBox( diff --git a/packages/neon/lib/src/apps/files/pages/details.dart b/packages/neon/lib/src/apps/files/pages/details.dart index 383af2ca..ecc695d6 100644 --- a/packages/neon/lib/src/apps/files/pages/details.dart +++ b/packages/neon/lib/src/apps/files/pages/details.dart @@ -11,7 +11,7 @@ class FilesDetailsPage extends StatelessWidget { final FileDetails details; @override - Widget build(BuildContext context) => Scaffold( + Widget build(final BuildContext context) => Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar( title: Text(details.name), diff --git a/packages/neon/lib/src/apps/files/pages/main.dart b/packages/neon/lib/src/apps/files/pages/main.dart index b17e6286..adbae938 100644 --- a/packages/neon/lib/src/apps/files/pages/main.dart +++ b/packages/neon/lib/src/apps/files/pages/main.dart @@ -23,7 +23,7 @@ class _FilesMainPageState extends State { } @override - Widget build(BuildContext context) => FilesBrowserView( + Widget build(final BuildContext context) => FilesBrowserView( bloc: widget.bloc.browser, filesBloc: widget.bloc, onPickFile: (final details) async { diff --git a/packages/neon/lib/src/apps/files/widgets/file_preview.dart b/packages/neon/lib/src/apps/files/widgets/file_preview.dart index 2b94277f..f3712073 100644 --- a/packages/neon/lib/src/apps/files/widgets/file_preview.dart +++ b/packages/neon/lib/src/apps/files/widgets/file_preview.dart @@ -24,7 +24,7 @@ class FilePreview extends StatelessWidget { final bool withBackground; @override - Widget build(BuildContext context) { + Widget build(final BuildContext context) { final color = this.color ?? Theme.of(context).colorScheme.primary; return SizedBox( width: width.toDouble(), diff --git a/packages/neon/lib/src/apps/news/app.dart b/packages/neon/lib/src/apps/news/app.dart index 9ad8e6bc..9b8fb1a4 100644 --- a/packages/neon/lib/src/apps/news/app.dart +++ b/packages/neon/lib/src/apps/news/app.dart @@ -54,23 +54,23 @@ class NewsApp extends AppImplementation { String id = 'news'; @override - String nameFromLocalization(AppLocalizations localizations) => localizations.newsName; + String nameFromLocalization(final AppLocalizations localizations) => localizations.newsName; @override - NewsAppSpecificOptions buildOptions(Storage storage) => NewsAppSpecificOptions(storage, platform); + NewsAppSpecificOptions buildOptions(final Storage storage) => NewsAppSpecificOptions(storage, platform); @override - NewsBloc buildBloc(NextcloudClient client) => NewsBloc( + NewsBloc buildBloc(final NextcloudClient client) => NewsBloc( options, requestManager, client, ); @override - Widget buildPage(BuildContext context, AppsBloc appsBloc) => NewsMainPage( + Widget buildPage(final BuildContext context, final AppsBloc appsBloc) => NewsMainPage( bloc: appsBloc.getAppBloc(this), ); @override - BehaviorSubject? getUnreadCounter(AppsBloc appsBloc) => appsBloc.getAppBloc(this).unreadCounter; + BehaviorSubject? getUnreadCounter(final AppsBloc appsBloc) => appsBloc.getAppBloc(this).unreadCounter; } diff --git a/packages/neon/lib/src/apps/news/blocs/articles.dart b/packages/neon/lib/src/apps/news/blocs/articles.dart index 016badf1..3fbde7d5 100644 --- a/packages/neon/lib/src/apps/news/blocs/articles.dart +++ b/packages/neon/lib/src/apps/news/blocs/articles.dart @@ -182,10 +182,10 @@ class NewsArticlesBloc extends $NewsArticlesBloc { @override void dispose() { - _articlesSubject.close(); - _filterTypeSubject.close(); - _articleUpdateController.close(); - _errorsStreamController.close(); + unawaited(_articlesSubject.close()); + unawaited(_filterTypeSubject.close()); + unawaited(_articleUpdateController.close()); + unawaited(_errorsStreamController.close()); super.dispose(); } diff --git a/packages/neon/lib/src/apps/news/blocs/news.dart b/packages/neon/lib/src/apps/news/blocs/news.dart index ef89e558..fe3adca6 100644 --- a/packages/neon/lib/src/apps/news/blocs/news.dart +++ b/packages/neon/lib/src/apps/news/blocs/news.dart @@ -237,10 +237,10 @@ class NewsBloc extends $NewsBloc { @override void dispose() { - _foldersSubject.close(); - _feedsSubject.close(); - _errorsStreamController.close(); - _unreadCounterSubject.close(); + unawaited(_foldersSubject.close()); + unawaited(_feedsSubject.close()); + unawaited(_errorsStreamController.close()); + unawaited(_unreadCounterSubject.close()); super.dispose(); } diff --git a/packages/neon/lib/src/apps/news/dialogs/add_feed.dart b/packages/neon/lib/src/apps/news/dialogs/add_feed.dart index a7e06285..5c795a2e 100644 --- a/packages/neon/lib/src/apps/news/dialogs/add_feed.dart +++ b/packages/neon/lib/src/apps/news/dialogs/add_feed.dart @@ -30,14 +30,16 @@ class _NewsAddFeedDialogState extends State { void initState() { super.initState(); - Clipboard.getData(Clipboard.kTextPlain).then((final clipboardContent) { - if (clipboardContent != null && clipboardContent.text != null) { - final uri = Uri.tryParse(clipboardContent.text!); - if (uri != null && (uri.scheme == 'http' || uri.scheme == 'https')) { - controller.text = clipboardContent.text!; + unawaited( + Clipboard.getData(Clipboard.kTextPlain).then((final clipboardContent) { + if (clipboardContent != null && clipboardContent.text != null) { + final uri = Uri.tryParse(clipboardContent.text!); + if (uri != null && (uri.scheme == 'http' || uri.scheme == 'https')) { + controller.text = clipboardContent.text!; + } } - } - }); + }), + ); } @override diff --git a/packages/neon/lib/src/apps/news/pages/article.dart b/packages/neon/lib/src/apps/news/pages/article.dart index 1b032802..dee54833 100644 --- a/packages/neon/lib/src/apps/news/pages/article.dart +++ b/packages/neon/lib/src/apps/news/pages/article.dart @@ -37,9 +37,9 @@ class _NewsArticlePageState extends State { } }); - WidgetsBinding.instance.addPostFrameCallback((final _) { + WidgetsBinding.instance.addPostFrameCallback((final _) async { if (Provider.of(context, listen: false).canUseWakelock) { - Wakelock.enable(); + await Wakelock.enable(); } }); diff --git a/packages/neon/lib/src/apps/notes/app.dart b/packages/neon/lib/src/apps/notes/app.dart index 28c08679..0ba8ea07 100644 --- a/packages/neon/lib/src/apps/notes/app.dart +++ b/packages/neon/lib/src/apps/notes/app.dart @@ -41,23 +41,23 @@ class NotesApp extends AppImplementation { String id = 'notes'; @override - String nameFromLocalization(AppLocalizations localizations) => localizations.notesName; + String nameFromLocalization(final AppLocalizations localizations) => localizations.notesName; @override - NotesAppSpecificOptions buildOptions(Storage storage) => NotesAppSpecificOptions(storage); + NotesAppSpecificOptions buildOptions(final Storage storage) => NotesAppSpecificOptions(storage); @override - NotesBloc buildBloc(NextcloudClient client) => NotesBloc( + NotesBloc buildBloc(final NextcloudClient client) => NotesBloc( options, requestManager, client, ); @override - Widget buildPage(BuildContext context, AppsBloc appsBloc) => NotesMainPage( + Widget buildPage(final BuildContext context, final AppsBloc appsBloc) => NotesMainPage( bloc: appsBloc.getAppBloc(this), ); @override - BehaviorSubject? getUnreadCounter(AppsBloc appsBloc) => null; + BehaviorSubject? getUnreadCounter(final AppsBloc appsBloc) => null; } diff --git a/packages/neon/lib/src/apps/notes/blocs/notes.dart b/packages/neon/lib/src/apps/notes/blocs/notes.dart index 52b268c5..516bc907 100644 --- a/packages/neon/lib/src/apps/notes/blocs/notes.dart +++ b/packages/neon/lib/src/apps/notes/blocs/notes.dart @@ -90,8 +90,8 @@ class NotesBloc extends $NotesBloc { @override void dispose() { - _notesSubject.close(); - _errorsStreamController.close(); + unawaited(_notesSubject.close()); + unawaited(_errorsStreamController.close()); super.dispose(); } diff --git a/packages/neon/lib/src/apps/notes/pages/note.dart b/packages/neon/lib/src/apps/notes/pages/note.dart index 53786a13..3980aefa 100644 --- a/packages/neon/lib/src/apps/notes/pages/note.dart +++ b/packages/neon/lib/src/apps/notes/pages/note.dart @@ -72,9 +72,9 @@ class _NotesNotePageState extends State { } }); - WidgetsBinding.instance.addPostFrameCallback((final _) { + WidgetsBinding.instance.addPostFrameCallback((final _) async { if (Provider.of(context, listen: false).canUseWakelock) { - Wakelock.enable(); + await Wakelock.enable(); } if (widget.bloc.options.defaultNoteViewTypeOption.value == DefaultNoteViewType.edit || widget.note.content!.isEmpty) { @@ -189,9 +189,9 @@ class _NotesNotePageState extends State { ) : MarkdownBody( data: _contentController.text, - onTapLink: (final text, final href, final title) { + onTapLink: (final text, final href, final title) async { if (href != null) { - launchUrlString( + await launchUrlString( href, mode: LaunchMode.externalApplication, ); diff --git a/packages/neon/lib/src/apps/notifications/app.dart b/packages/neon/lib/src/apps/notifications/app.dart index 24c948af..c2fcb66d 100644 --- a/packages/neon/lib/src/apps/notifications/app.dart +++ b/packages/neon/lib/src/apps/notifications/app.dart @@ -21,24 +21,24 @@ class NotificationsApp extends AppImplementation localizations.notificationsName; + String nameFromLocalization(final AppLocalizations localizations) => localizations.notificationsName; @override - NotificationsAppSpecificOptions buildOptions(Storage storage) => NotificationsAppSpecificOptions(storage); + NotificationsAppSpecificOptions buildOptions(final Storage storage) => NotificationsAppSpecificOptions(storage); @override - NotificationsBloc buildBloc(NextcloudClient client) => NotificationsBloc( + NotificationsBloc buildBloc(final NextcloudClient client) => NotificationsBloc( options, requestManager, client, ); @override - Widget buildPage(BuildContext context, AppsBloc appsBloc) => NotificationsMainPage( + Widget buildPage(final BuildContext context, final AppsBloc appsBloc) => NotificationsMainPage( bloc: appsBloc.getAppBloc(this), ); @override - BehaviorSubject? getUnreadCounter(AppsBloc appsBloc) => + BehaviorSubject? getUnreadCounter(final AppsBloc appsBloc) => appsBloc.getAppBloc(this).unreadCounter; } diff --git a/packages/neon/lib/src/apps/notifications/blocs/notifications.dart b/packages/neon/lib/src/apps/notifications/blocs/notifications.dart index 7f866dcf..47421c1c 100644 --- a/packages/neon/lib/src/apps/notifications/blocs/notifications.dart +++ b/packages/neon/lib/src/apps/notifications/blocs/notifications.dart @@ -83,9 +83,9 @@ class NotificationsBloc extends $NotificationsBloc { @override void dispose() { - _notificationsSubject.close(); - _errorsStreamController.close(); - _unreadCounterSubject.close(); + unawaited(_notificationsSubject.close()); + unawaited(_errorsStreamController.close()); + unawaited(_unreadCounterSubject.close()); super.dispose(); } diff --git a/packages/neon/lib/src/apps/notifications/pages/main.dart b/packages/neon/lib/src/apps/notifications/pages/main.dart index a2ee47a3..9c94278a 100644 --- a/packages/neon/lib/src/apps/notifications/pages/main.dart +++ b/packages/neon/lib/src/apps/notifications/pages/main.dart @@ -23,7 +23,8 @@ class _NotificationsMainPageState extends State { } @override - Widget build(BuildContext context) => StandardRxResultBuilder>( + Widget build(final BuildContext context) => + StandardRxResultBuilder>( bloc: widget.bloc, state: (final bloc) => bloc.notifications, builder: ( @@ -130,7 +131,7 @@ class _NotificationsMainPageState extends State { actions: [ ElevatedButton( style: ElevatedButton.styleFrom( - primary: Colors.red, + backgroundColor: Colors.red, ), onPressed: () { Navigator.of(context).pop(); diff --git a/packages/neon/lib/src/blocs/accounts.dart b/packages/neon/lib/src/blocs/accounts.dart index 6c0234c3..31e78167 100644 --- a/packages/neon/lib/src/blocs/accounts.dart +++ b/packages/neon/lib/src/blocs/accounts.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'package:neon/src/blocs/user_details.dart'; @@ -106,12 +107,14 @@ class AccountsBloc extends $AccountsBloc { final lastUsedAccountID = _storage.getString(_keyLastUsedAccount); _activeAccountSubject.add(accounts.singleWhere((final account) => account.id == lastUsedAccountID)); } else { - _globalOptions.initialAccount.stream.first.then((final lastAccount) { - final matches = accounts.where((final account) => account.id == lastAccount).toList(); - if (matches.isNotEmpty) { - _activeAccountSubject.add(matches[0]); - } - }); + unawaited( + _globalOptions.initialAccount.stream.first.then((final lastAccount) { + final matches = accounts.where((final account) => account.id == lastAccount).toList(); + if (matches.isNotEmpty) { + _activeAccountSubject.add(matches[0]); + } + }), + ); } } @@ -170,8 +173,8 @@ class AccountsBloc extends $AccountsBloc { @override void dispose() { - _activeAccountSubject.close(); - _accountsSubject.close(); + unawaited(_activeAccountSubject.close()); + unawaited(_accountsSubject.close()); for (final bloc in _userDetailsBlocs.values) { bloc.dispose(); } diff --git a/packages/neon/lib/src/blocs/apps.dart b/packages/neon/lib/src/blocs/apps.dart index 05499277..612adfd9 100644 --- a/packages/neon/lib/src/blocs/apps.dart +++ b/packages/neon/lib/src/blocs/apps.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/foundation.dart'; import 'package:neon/src/blocs/accounts.dart'; import 'package:neon/src/models/account.dart'; @@ -65,20 +67,22 @@ class AppsBloc extends $AppsBloc { _accountsBloc.pushNotificationApp = null; } else { final options = _accountsBloc.getOptions(_account)!..updateApps(appImplementations); - options.initialApp.stream.first.then((var initialApp) { - if (initialApp == null) { - if (appImplementations.where((final a) => a.id == 'files').isNotEmpty) { - initialApp = 'files'; - } else if (appImplementations.isNotEmpty) { - // This should never happen, because the files app is always installed and can not be removed, but just in - // case this changes at a later point. - initialApp = appImplementations[0].id; + unawaited( + options.initialApp.stream.first.then((var initialApp) { + if (initialApp == null) { + if (appImplementations.where((final a) => a.id == 'files').isNotEmpty) { + initialApp = 'files'; + } else if (appImplementations.isNotEmpty) { + // This should never happen, because the files app is always installed and can not be removed, but just in + // case this changes at a later point. + initialApp = appImplementations[0].id; + } + } + if (!_activeAppSubject.hasValue) { + setActiveApp(initialApp); } - } - if (!_activeAppSubject.hasValue) { - setActiveApp(initialApp); - } - }); + }), + ); } } }); @@ -130,8 +134,8 @@ class AppsBloc extends $AppsBloc { @override void dispose() { - _appsSubject.close(); - _activeAppSubject.close(); + unawaited(_appsSubject.close()); + unawaited(_activeAppSubject.close()); for (final key in _blocs.keys) { _blocs[key]!.dispose(); } diff --git a/packages/neon/lib/src/blocs/capabilities.dart b/packages/neon/lib/src/blocs/capabilities.dart index ecd6dd76..e67da2e5 100644 --- a/packages/neon/lib/src/blocs/capabilities.dart +++ b/packages/neon/lib/src/blocs/capabilities.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:neon/src/models/account.dart'; import 'package:neon/src/neon.dart'; import 'package:nextcloud/nextcloud.dart'; @@ -48,7 +50,7 @@ class CapabilitiesBloc extends $CapabilitiesBloc { @override void dispose() { - _capabilitiesSubject.close(); + unawaited(_capabilitiesSubject.close()); super.dispose(); } diff --git a/packages/neon/lib/src/blocs/login.dart b/packages/neon/lib/src/blocs/login.dart index 6a976279..2238a554 100644 --- a/packages/neon/lib/src/blocs/login.dart +++ b/packages/neon/lib/src/blocs/login.dart @@ -86,10 +86,10 @@ class LoginBloc extends $LoginBloc { @override void dispose() { _cancelPollTimer(); - _serverURLSubject.close(); - _serverConnectionStateSubject.close(); - _loginFlowInitSubject.close(); - _loginFlowResultSubject.close(); + unawaited(_serverURLSubject.close()); + unawaited(_serverConnectionStateSubject.close()); + unawaited(_loginFlowInitSubject.close()); + unawaited(_loginFlowResultSubject.close()); super.dispose(); } diff --git a/packages/neon/lib/src/blocs/push_notifications.dart b/packages/neon/lib/src/blocs/push_notifications.dart index 63dd51b0..d023e048 100644 --- a/packages/neon/lib/src/blocs/push_notifications.dart +++ b/packages/neon/lib/src/blocs/push_notifications.dart @@ -28,14 +28,14 @@ class PushNotificationsBloc extends $PushNotificationsBloc { this._platform, ) { if (_platform.canUsePushNotifications) { - UnifiedPush.getDistributors().then(_globalOptions.updateDistributors); + unawaited(UnifiedPush.getDistributors().then(_globalOptions.updateDistributors)); _globalOptions.pushNotificationsEnabled.stream.listen((final enabled) async { if (enabled != _pushNotificationsEnabled) { _pushNotificationsEnabled = enabled; if (enabled) { // We just use a single RSA keypair for all accounts - _keypair = PushUtils.loadRSAKeypair(_storage); + _keypair = await PushUtils.loadRSAKeypair(_storage); await _setupUnifiedPush(); } } @@ -138,7 +138,7 @@ class PushNotificationsBloc extends $PushNotificationsBloc { @override void dispose() { - _notificationsController.close(); + unawaited(_notificationsController.close()); super.dispose(); } diff --git a/packages/neon/lib/src/blocs/user_details.dart b/packages/neon/lib/src/blocs/user_details.dart index ca0f263a..2d07d19d 100644 --- a/packages/neon/lib/src/blocs/user_details.dart +++ b/packages/neon/lib/src/blocs/user_details.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:neon/src/models/account.dart'; import 'package:neon/src/neon.dart'; import 'package:nextcloud/nextcloud.dart'; @@ -45,7 +47,7 @@ class UserDetailsBloc extends $UserDetailsBloc { @override void dispose() { - _userDetailsSubject.close(); + unawaited(_userDetailsSubject.close()); super.dispose(); } diff --git a/packages/neon/lib/src/blocs/user_status.dart b/packages/neon/lib/src/blocs/user_status.dart index d84ebbdc..cca94af7 100644 --- a/packages/neon/lib/src/blocs/user_status.dart +++ b/packages/neon/lib/src/blocs/user_status.dart @@ -80,8 +80,8 @@ class UserStatusBloc extends $UserStatusBloc { @override void dispose() { _cancelTimer(); - _activeAccountStreamSubscription.cancel(); - _userStatusSubject.close(); + unawaited(_activeAccountStreamSubscription.cancel()); + unawaited(_userStatusSubject.close()); super.dispose(); } diff --git a/packages/neon/lib/src/models/account.dart b/packages/neon/lib/src/models/account.dart index 5ed9194c..0dae71cf 100644 --- a/packages/neon/lib/src/models/account.dart +++ b/packages/neon/lib/src/models/account.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'package:crypto/crypto.dart'; @@ -11,7 +12,7 @@ import 'package:settings/settings.dart'; part 'account.g.dart'; -String userAgent(PackageInfo packageInfo) => 'Neon ${packageInfo.version}+${packageInfo.buildNumber}'; +String userAgent(final PackageInfo packageInfo) => 'Neon ${packageInfo.version}+${packageInfo.buildNumber}'; @JsonSerializable() class Account { @@ -50,7 +51,7 @@ class Account { NextcloudClient? _client; - void setupClient(PackageInfo packageInfo) { + void setupClient(final PackageInfo packageInfo) { _client ??= NextcloudClient( serverURL, username: username, @@ -115,7 +116,7 @@ class AccountSpecificOptions { } void dispose() { - _appIDsSubject.close(); + unawaited(_appIDsSubject.close()); for (final option in options) { option.dispose(); } diff --git a/packages/neon/lib/src/models/nextcloud_notification.dart b/packages/neon/lib/src/models/nextcloud_notification.dart index a62fd1fe..31df58c4 100644 --- a/packages/neon/lib/src/models/nextcloud_notification.dart +++ b/packages/neon/lib/src/models/nextcloud_notification.dart @@ -29,4 +29,4 @@ class NextcloudNotification { NotificationsPushNotificationDecryptedSubject _fromJsonSubject(final Map data) => NotificationsPushNotificationDecryptedSubject.fromJson(data)!; -Map? _toJsonSubject(NotificationsPushNotificationDecryptedSubject subject) => subject.toJson(); +Map? _toJsonSubject(final NotificationsPushNotificationDecryptedSubject subject) => subject.toJson(); diff --git a/packages/neon/lib/src/neon.dart b/packages/neon/lib/src/neon.dart index bc935233..14300e31 100644 --- a/packages/neon/lib/src/neon.dart +++ b/packages/neon/lib/src/neon.dart @@ -4,7 +4,6 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'dart:math'; -import 'dart:typed_data'; import 'package:collection/collection.dart'; import 'package:crypto/crypto.dart'; diff --git a/packages/neon/lib/src/pages/home/home.dart b/packages/neon/lib/src/pages/home/home.dart index db63043b..68b0d8df 100644 --- a/packages/neon/lib/src/pages/home/home.dart +++ b/packages/neon/lib/src/pages/home/home.dart @@ -48,7 +48,7 @@ class _HomePageState extends State with tray.TrayListener, WindowListe _requestManager, widget.account.client, ); - _capabilitiesBloc.capabilities.listen((final result) { + _capabilitiesBloc.capabilities.listen((final result) async { if (result.data != null) { widget.onThemeChanged(result.data!.capabilities!.theming!); @@ -56,14 +56,14 @@ class _HomePageState extends State with tray.TrayListener, WindowListe if (result is ResultSuccess) { const requiredMajorVersion = 24; if (result.data!.version!.major! < requiredMajorVersion) { - showDialog( + await showDialog( context: context, builder: (final context) => AlertDialog( title: Text(AppLocalizations.of(context).errorUnsupportedNextcloudVersion(requiredMajorVersion)), actions: [ ElevatedButton( style: ElevatedButton.styleFrom( - primary: Colors.red, + backgroundColor: Colors.red, ), onPressed: () { Navigator.of(context).pop(); @@ -200,9 +200,9 @@ class _HomePageState extends State with tray.TrayListener, WindowListe } @override - void onTrayMenuItemClick(tray.MenuItem menuItem) { + void onTrayMenuItemClick(final tray.MenuItem menuItem) { if (menuItem.key != null) { - _handleShortcut(menuItem.key!); + unawaited(_handleShortcut(menuItem.key!)); } } diff --git a/packages/neon/lib/src/pages/settings/settings.dart b/packages/neon/lib/src/pages/settings/settings.dart index d355d29d..af973ab7 100644 --- a/packages/neon/lib/src/pages/settings/settings.dart +++ b/packages/neon/lib/src/pages/settings/settings.dart @@ -179,8 +179,8 @@ class _SettingsPageState extends State { for (final account in accountsSnapshot.data!) ...[ AccountSettingsTile( account: account, - onTap: () { - Navigator.of(context).push( + onTap: () async { + await Navigator.of(context).push( MaterialPageRoute( builder: (final context) => AccountSpecificSettingsPage( bloc: accountsBloc, diff --git a/packages/neon/lib/src/utils/app_implementation.dart b/packages/neon/lib/src/utils/app_implementation.dart index bbaabfde..57a5867b 100644 --- a/packages/neon/lib/src/utils/app_implementation.dart +++ b/packages/neon/lib/src/utils/app_implementation.dart @@ -15,8 +15,8 @@ List getAppImplementations( abstract class AppImplementation { AppImplementation( final SharedPreferences sharedPreferences, - final this.requestManager, - final this.platform, + this.requestManager, + this.platform, ) { final storage = Storage('app-$id', sharedPreferences); options = buildOptions(storage); @@ -26,17 +26,17 @@ abstract class AppImplementation nameFromLocalization(AppLocalizations.of(context)); + String nameFromLocalization(final AppLocalizations localizations); + String name(final BuildContext context) => nameFromLocalization(AppLocalizations.of(context)); late final R options; - R buildOptions(Storage storage); + R buildOptions(final Storage storage); T buildBloc(final NextcloudClient client); - BehaviorSubject? getUnreadCounter(AppsBloc appsBloc); + BehaviorSubject? getUnreadCounter(final AppsBloc appsBloc); - Widget buildPage(BuildContext context, AppsBloc appsBloc); + Widget buildPage(final BuildContext context, final AppsBloc appsBloc); Widget buildIcon( final BuildContext context, { diff --git a/packages/neon/lib/src/utils/confirmation_dialog.dart b/packages/neon/lib/src/utils/confirmation_dialog.dart index 775460a8..5a037187 100644 --- a/packages/neon/lib/src/utils/confirmation_dialog.dart +++ b/packages/neon/lib/src/utils/confirmation_dialog.dart @@ -9,7 +9,7 @@ Future showConfirmationDialog(final BuildContext context, final String tit actions: [ ElevatedButton( style: ElevatedButton.styleFrom( - primary: Colors.red, + backgroundColor: Colors.red, ), onPressed: () { Navigator.of(context).pop(false); @@ -18,7 +18,7 @@ Future showConfirmationDialog(final BuildContext context, final String tit ), ElevatedButton( style: ElevatedButton.styleFrom( - primary: Colors.green, + backgroundColor: Colors.green, ), onPressed: () { Navigator.of(context).pop(true); diff --git a/packages/neon/lib/src/utils/global_options.dart b/packages/neon/lib/src/utils/global_options.dart index c7f2b2c5..60c2641f 100644 --- a/packages/neon/lib/src/utils/global_options.dart +++ b/packages/neon/lib/src/utils/global_options.dart @@ -77,8 +77,8 @@ class GlobalOptions { } void dispose() { - _accountsIDsSubject.close(); - _themeOLEDAsDarkEnabledSubject.close(); + unawaited(_accountsIDsSubject.close()); + unawaited(_themeOLEDAsDarkEnabledSubject.close()); for (final option in options) { option.dispose(); } diff --git a/packages/neon/lib/src/utils/push_utils.dart b/packages/neon/lib/src/utils/push_utils.dart index c451b2fb..c9f9307a 100644 --- a/packages/neon/lib/src/utils/push_utils.dart +++ b/packages/neon/lib/src/utils/push_utils.dart @@ -1,7 +1,7 @@ part of '../neon.dart'; class PushUtils { - static RSAKeypair loadRSAKeypair(final Storage storage) { + static Future loadRSAKeypair(final Storage storage) async { const keyDevicePrivateKey = 'device-private-key'; late RSAKeypair keypair; @@ -10,7 +10,7 @@ class PushUtils { // The key size has to be 2048, other sizes are not accepted by Nextcloud (at the moment at least) // ignore: avoid_redundant_argument_values keypair = RSAKeypair.fromRandom(keySize: 2048); - storage.setString(keyDevicePrivateKey, keypair.privateKey.toPEM()); + await storage.setString(keyDevicePrivateKey, keypair.privateKey.toPEM()); } else { keypair = RSAKeypair(RSAPrivateKey.fromPEM(storage.getString(keyDevicePrivateKey)!)); } @@ -47,7 +47,7 @@ class PushUtils { ); final sharedPreferences = await SharedPreferences.getInstance(); - final keypair = loadRSAKeypair(Storage('notifications', sharedPreferences)); + final keypair = await loadRSAKeypair(Storage('notifications', sharedPreferences)); final data = json.decode(utf8.decode(message)) as Map; final notification = NextcloudNotification( accountID: instance, @@ -69,7 +69,8 @@ class PushUtils { return; } - final parts = (await findSystemLocale()).split('_').map((final a) => a.split('.')).reduce((a, b) => [...a, ...b]); + final parts = + (await findSystemLocale()).split('_').map((final a) => a.split('.')).reduce((final a, final b) => [...a, ...b]); final localizations = await AppLocalizations.delegate.load(Locale(parts[0], parts.length > 1 ? parts[1] : null)); final platform = await getNeonPlatform(); @@ -121,5 +122,5 @@ class PushUtils { final String instance, final NextcloudNotification notification, ) => - sha256.convert(utf8.encode('$instance${notification.subject.nid!}')).bytes.reduce((a, b) => a + b); + sha256.convert(utf8.encode('$instance${notification.subject.nid!}')).bytes.reduce((final a, final b) => a + b); } diff --git a/packages/neon/lib/src/utils/theme.dart b/packages/neon/lib/src/utils/theme.dart index 6cad9330..fdad635a 100644 --- a/packages/neon/lib/src/utils/theme.dart +++ b/packages/neon/lib/src/utils/theme.dart @@ -118,8 +118,8 @@ ThemeData getThemeFromNextcloudTheme( ), elevatedButtonTheme: ElevatedButtonThemeData( style: ElevatedButton.styleFrom( - onPrimary: onPrimaryColor, - primary: primaryColor, + foregroundColor: onPrimaryColor, + backgroundColor: primaryColor, ).copyWith( elevation: ButtonStyleButton.allOrNull(0), ), diff --git a/packages/neon/lib/src/widgets/image_wrapper.dart b/packages/neon/lib/src/widgets/image_wrapper.dart index 05d49812..2c98cb20 100644 --- a/packages/neon/lib/src/widgets/image_wrapper.dart +++ b/packages/neon/lib/src/widgets/image_wrapper.dart @@ -17,7 +17,7 @@ class ImageWrapper extends StatelessWidget { final BorderRadius? borderRadius; @override - Widget build(BuildContext context) => SizedBox( + Widget build(final BuildContext context) => SizedBox( width: width, height: height, child: DecoratedBox( diff --git a/packages/nextcloud/analysis_options.yaml b/packages/nextcloud/analysis_options.yaml index 56fa5bdb..666dd03b 100644 --- a/packages/nextcloud/analysis_options.yaml +++ b/packages/nextcloud/analysis_options.yaml @@ -1,9 +1,5 @@ include: package:nit_picking/dart.yaml -linter: - rules: - prefer_final_parameters: false # Disabled until super.X is no longer complained about in constructors - analyzer: exclude: - 'lib/src/clients/common' diff --git a/packages/nextcloud/lib/src/clients/notifications.dart b/packages/nextcloud/lib/src/clients/notifications.dart index 42d87060..3d1cf08f 100644 --- a/packages/nextcloud/lib/src/clients/notifications.dart +++ b/packages/nextcloud/lib/src/clients/notifications.dart @@ -26,7 +26,7 @@ class NextcloudNotificationsClient extends DefaultApi { @override @Deprecated('Use registerDeviceAtServer instead') Future registerDevice( - NotificationsPushServerDevice notificationsPushServerDevice, + final NotificationsPushServerDevice notificationsPushServerDevice, ) => throw Exception('Use registerDeviceAtServer instead'); diff --git a/packages/nextcloud_push_proxy/analysis_options.yaml b/packages/nextcloud_push_proxy/analysis_options.yaml index 0cc523ce..0ed2fb9f 100644 --- a/packages/nextcloud_push_proxy/analysis_options.yaml +++ b/packages/nextcloud_push_proxy/analysis_options.yaml @@ -1,5 +1 @@ include: package:nit_picking/dart.yaml - -linter: - rules: - prefer_final_parameters: false # Disabled until super.X is no longer complained about in constructors diff --git a/packages/nextcloud_push_proxy/lib/nextcloud_push_proxy.dart b/packages/nextcloud_push_proxy/lib/nextcloud_push_proxy.dart index 8615b081..84f978ba 100644 --- a/packages/nextcloud_push_proxy/lib/nextcloud_push_proxy.dart +++ b/packages/nextcloud_push_proxy/lib/nextcloud_push_proxy.dart @@ -41,7 +41,7 @@ class NextcloudPushProxy { ..post('/notifications', _notificationsHandler) ..get('/health', (final _) async => Response.ok('')); - Future _devicesHandler(Request request) async { + Future _devicesHandler(final Request request) async { final data = Uri(query: await request.readAsString()).queryParameters; _onNewDeviceController.add( PushProxyDevice( @@ -54,7 +54,7 @@ class NextcloudPushProxy { return Response.ok(''); } - Future _notificationsHandler(Request request) async { + Future _notificationsHandler(final Request request) async { final data = Uri(query: await request.readAsString()).queryParameters; for (final notification in data.values) { final notificationData = json.decode(notification) as Map; @@ -119,7 +119,7 @@ class PushProxyDevice { required this.userPublicKey, }); - factory PushProxyDevice.fromJson(Map data) => PushProxyDevice( + factory PushProxyDevice.fromJson(final Map data) => PushProxyDevice( pushToken: data['pushToken'] as String, deviceIdentifier: data['deviceIdentifier'] as String, deviceIdentifierSignature: data['deviceIdentifierSignature'] as String, diff --git a/packages/settings/analysis_options.yaml b/packages/settings/analysis_options.yaml index 7dd8e1f6..c7c10b7d 100644 --- a/packages/settings/analysis_options.yaml +++ b/packages/settings/analysis_options.yaml @@ -1,5 +1 @@ include: package:nit_picking/flutter.yaml - -linter: - rules: - prefer_final_parameters: false # Disabled until super.X is no longer complained about in constructors diff --git a/packages/settings/lib/settings.dart b/packages/settings/lib/settings.dart index 4b6c2cc2..1682bcf9 100644 --- a/packages/settings/lib/settings.dart +++ b/packages/settings/lib/settings.dart @@ -1,5 +1,7 @@ library settings; +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:intersperse/intersperse.dart'; import 'package:rxdart/rxdart.dart'; diff --git a/packages/settings/lib/src/options/option.dart b/packages/settings/lib/src/options/option.dart index 648db375..8f47635c 100644 --- a/packages/settings/lib/src/options/option.dart +++ b/packages/settings/lib/src/options/option.dart @@ -47,8 +47,8 @@ abstract class Option { } void dispose() { - stream.close(); - enabled.close(); + unawaited(stream.close()); + unawaited(enabled.close()); } Future set(final T value); diff --git a/packages/settings/lib/src/options/select_option.dart b/packages/settings/lib/src/options/select_option.dart index 7eb4a763..5917e672 100644 --- a/packages/settings/lib/src/options/select_option.dart +++ b/packages/settings/lib/src/options/select_option.dart @@ -11,15 +11,17 @@ class SelectOption extends Option { super.enabled, }) { stream = BehaviorSubject(); - values.first.then((final vs) async { - final valueStr = storage.getString(key); - T? initialValue; + unawaited( + values.first.then((final vs) async { + final valueStr = storage.getString(key); + T? initialValue; - if (valueStr != null) { - initialValue = _fromString(vs, valueStr); - } - stream.add(initialValue ?? await defaultValue.first); - }); + if (valueStr != null) { + initialValue = _fromString(vs, valueStr); + } + stream.add(initialValue ?? await defaultValue.first); + }), + ); } T? _fromString(final Map vs, final String? valueStr) { diff --git a/packages/spec_templates/analysis_options.yaml b/packages/spec_templates/analysis_options.yaml index eba2d9cc..0ed2fb9f 100644 --- a/packages/spec_templates/analysis_options.yaml +++ b/packages/spec_templates/analysis_options.yaml @@ -1,5 +1 @@ include: package:nit_picking/dart.yaml - -analyzer: - errors: - import_of_legacy_library_into_null_safe: ignore