Browse Source

Cleanup linting issues

pull/56/head
jld3103 2 years ago
parent
commit
1934399978
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 4
      packages/file_icons/analysis_options.yaml
  2. 4
      packages/neon/analysis_options.yaml
  3. 26
      packages/neon/integration_test/screenshot_test.dart
  4. 4
      packages/neon/lib/app.dart
  5. 10
      packages/neon/lib/src/apps/files/app.dart
  6. 6
      packages/neon/lib/src/apps/files/blocs/browser.dart
  7. 6
      packages/neon/lib/src/apps/files/blocs/files.dart
  8. 2
      packages/neon/lib/src/apps/files/dialogs/choose_folder.dart
  9. 2
      packages/neon/lib/src/apps/files/pages/details.dart
  10. 2
      packages/neon/lib/src/apps/files/pages/main.dart
  11. 2
      packages/neon/lib/src/apps/files/widgets/file_preview.dart
  12. 10
      packages/neon/lib/src/apps/news/app.dart
  13. 8
      packages/neon/lib/src/apps/news/blocs/articles.dart
  14. 8
      packages/neon/lib/src/apps/news/blocs/news.dart
  15. 4
      packages/neon/lib/src/apps/news/dialogs/add_feed.dart
  16. 4
      packages/neon/lib/src/apps/news/pages/article.dart
  17. 10
      packages/neon/lib/src/apps/notes/app.dart
  18. 4
      packages/neon/lib/src/apps/notes/blocs/notes.dart
  19. 8
      packages/neon/lib/src/apps/notes/pages/note.dart
  20. 10
      packages/neon/lib/src/apps/notifications/app.dart
  21. 6
      packages/neon/lib/src/apps/notifications/blocs/notifications.dart
  22. 5
      packages/neon/lib/src/apps/notifications/pages/main.dart
  23. 9
      packages/neon/lib/src/blocs/accounts.dart
  24. 10
      packages/neon/lib/src/blocs/apps.dart
  25. 4
      packages/neon/lib/src/blocs/capabilities.dart
  26. 8
      packages/neon/lib/src/blocs/login.dart
  27. 6
      packages/neon/lib/src/blocs/push_notifications.dart
  28. 4
      packages/neon/lib/src/blocs/user_details.dart
  29. 4
      packages/neon/lib/src/blocs/user_status.dart
  30. 7
      packages/neon/lib/src/models/account.dart
  31. 2
      packages/neon/lib/src/models/nextcloud_notification.dart
  32. 1
      packages/neon/lib/src/neon.dart
  33. 10
      packages/neon/lib/src/pages/home/home.dart
  34. 4
      packages/neon/lib/src/pages/settings/settings.dart
  35. 14
      packages/neon/lib/src/utils/app_implementation.dart
  36. 4
      packages/neon/lib/src/utils/confirmation_dialog.dart
  37. 4
      packages/neon/lib/src/utils/global_options.dart
  38. 11
      packages/neon/lib/src/utils/push_utils.dart
  39. 4
      packages/neon/lib/src/utils/theme.dart
  40. 2
      packages/neon/lib/src/widgets/image_wrapper.dart
  41. 4
      packages/nextcloud/analysis_options.yaml
  42. 2
      packages/nextcloud/lib/src/clients/notifications.dart
  43. 4
      packages/nextcloud_push_proxy/analysis_options.yaml
  44. 6
      packages/nextcloud_push_proxy/lib/nextcloud_push_proxy.dart
  45. 4
      packages/settings/analysis_options.yaml
  46. 2
      packages/settings/lib/settings.dart
  47. 4
      packages/settings/lib/src/options/option.dart
  48. 4
      packages/settings/lib/src/options/select_option.dart
  49. 4
      packages/spec_templates/analysis_options.yaml

4
packages/file_icons/analysis_options.yaml

@ -1,5 +1 @@
include: package:nit_picking/dart.yaml include: package:nit_picking/dart.yaml
linter:
rules:
prefer_final_parameters: false # Disabled until super.X is no longer complained about in constructors

4
packages/neon/analysis_options.yaml

@ -1,9 +1,5 @@
include: package:nit_picking/flutter.yaml include: package:nit_picking/flutter.yaml
linter:
rules:
prefer_final_parameters: false # Disabled until super.X is no longer complained about in constructors
analyzer: analyzer:
exclude: exclude:
- lib/src/l10n/** - lib/src/l10n/**

26
packages/neon/integration_test/screenshot_test.dart

@ -34,7 +34,7 @@ class MemorySharedPreferences implements SharedPreferences {
Future reload() async {} Future reload() async {}
@override @override
Future<bool> remove(String key) async { Future<bool> remove(final String key) async {
_data.remove(key); _data.remove(key);
return true; return true;
} }
@ -43,52 +43,52 @@ class MemorySharedPreferences implements SharedPreferences {
Set<String> getKeys() => _data.keys.toSet(); Set<String> getKeys() => _data.keys.toSet();
@override @override
bool containsKey(String key) => _data.keys.contains(key); bool containsKey(final String key) => _data.keys.contains(key);
@override @override
Object? get(String key) => _data[key]; Object? get(final String key) => _data[key];
@override @override
bool? getBool(String key) => _data[key] as bool?; bool? getBool(final String key) => _data[key] as bool?;
@override @override
double? getDouble(String key) => _data[key] as double?; double? getDouble(final String key) => _data[key] as double?;
@override @override
int? getInt(String key) => _data[key] as int?; int? getInt(final String key) => _data[key] as int?;
@override @override
String? getString(String key) => _data[key] as String?; String? getString(final String key) => _data[key] as String?;
@override @override
List<String>? getStringList(String key) => (_data[key] as List).cast<String>(); List<String>? getStringList(final String key) => (_data[key] as List).cast<String>();
@override @override
Future<bool> setBool(String key, bool value) async { Future<bool> setBool(final String key, final bool value) async {
_data[key] = value; _data[key] = value;
return true; return true;
} }
@override @override
Future<bool> setDouble(String key, double value) async { Future<bool> setDouble(final String key, final double value) async {
_data[key] = value; _data[key] = value;
return true; return true;
} }
@override @override
Future<bool> setInt(String key, int value) async { Future<bool> setInt(final String key, final int value) async {
_data[key] = value; _data[key] = value;
return true; return true;
} }
@override @override
Future<bool> setString(String key, String value) async { Future<bool> setString(final String key, final String value) async {
_data[key] = value; _data[key] = value;
return true; return true;
} }
@override @override
Future<bool> setStringList(String key, List<String> value) async { Future<bool> setStringList(final String key, final List<String> value) async {
_data[key] = value; _data[key] = value;
return true; return true;
} }

4
packages/neon/lib/app.dart

@ -1,3 +1,5 @@
import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart'; import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:neon/l10n/localizations.dart'; import 'package:neon/l10n/localizations.dart';
@ -84,7 +86,7 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver {
@override @override
void dispose() { void dispose() {
WidgetsBinding.instance.removeObserver(this); WidgetsBinding.instance.removeObserver(this);
_platformBrightness.close(); unawaited(_platformBrightness.close());
super.dispose(); super.dispose();
} }

10
packages/neon/lib/src/apps/files/app.dart

@ -46,13 +46,13 @@ class FilesApp extends AppImplementation<FilesBloc, FilesAppSpecificOptions> {
String id = 'files'; String id = 'files';
@override @override
String nameFromLocalization(AppLocalizations localizations) => localizations.filesName; String nameFromLocalization(final AppLocalizations localizations) => localizations.filesName;
@override @override
FilesAppSpecificOptions buildOptions(Storage storage) => FilesAppSpecificOptions(storage); FilesAppSpecificOptions buildOptions(final Storage storage) => FilesAppSpecificOptions(storage);
@override @override
FilesBloc buildBloc(NextcloudClient client) => FilesBloc( FilesBloc buildBloc(final NextcloudClient client) => FilesBloc(
options, options,
requestManager, requestManager,
client, client,
@ -60,10 +60,10 @@ class FilesApp extends AppImplementation<FilesBloc, FilesAppSpecificOptions> {
); );
@override @override
Widget buildPage(BuildContext context, AppsBloc appsBloc) => FilesMainPage( Widget buildPage(final BuildContext context, final AppsBloc appsBloc) => FilesMainPage(
bloc: appsBloc.getAppBloc(this), bloc: appsBloc.getAppBloc(this),
); );
@override @override
BehaviorSubject<int>? getUnreadCounter(AppsBloc appsBloc) => null; BehaviorSubject<int>? getUnreadCounter(final AppsBloc appsBloc) => null;
} }

6
packages/neon/lib/src/apps/files/blocs/browser.dart

@ -86,9 +86,9 @@ class FilesBrowserBloc extends $FilesBrowserBloc {
@override @override
void dispose() { void dispose() {
_filesSubject.close(); unawaited(_filesSubject.close());
_pathSubject.close(); unawaited(_pathSubject.close());
_errorsStreamController.close(); unawaited(_errorsStreamController.close());
super.dispose(); super.dispose();
} }

6
packages/neon/lib/src/apps/files/blocs/files.dart

@ -226,9 +226,9 @@ class FilesBloc extends $FilesBloc {
void dispose() { void dispose() {
_uploadQueue.dispose(); _uploadQueue.dispose();
_downloadQueue.dispose(); _downloadQueue.dispose();
_uploadTasksSubject.close(); unawaited(_uploadTasksSubject.close());
_downloadTasksSubject.close(); unawaited(_downloadTasksSubject.close());
_errorsStreamController.close(); unawaited(_errorsStreamController.close());
super.dispose(); super.dispose();
} }

2
packages/neon/lib/src/apps/files/dialogs/choose_folder.dart

@ -14,7 +14,7 @@ class FilesChooseFolderDialog extends StatelessWidget {
final List<String> originalPath; final List<String> originalPath;
@override @override
Widget build(BuildContext context) => AlertDialog( Widget build(final BuildContext context) => AlertDialog(
title: Text(AppLocalizations.of(context).filesChooseFolder), title: Text(AppLocalizations.of(context).filesChooseFolder),
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
content: SizedBox( content: SizedBox(

2
packages/neon/lib/src/apps/files/pages/details.dart

@ -11,7 +11,7 @@ class FilesDetailsPage extends StatelessWidget {
final FileDetails details; final FileDetails details;
@override @override
Widget build(BuildContext context) => Scaffold( Widget build(final BuildContext context) => Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: Text(details.name), title: Text(details.name),

2
packages/neon/lib/src/apps/files/pages/main.dart

@ -23,7 +23,7 @@ class _FilesMainPageState extends State<FilesMainPage> {
} }
@override @override
Widget build(BuildContext context) => FilesBrowserView( Widget build(final BuildContext context) => FilesBrowserView(
bloc: widget.bloc.browser, bloc: widget.bloc.browser,
filesBloc: widget.bloc, filesBloc: widget.bloc,
onPickFile: (final details) async { onPickFile: (final details) async {

2
packages/neon/lib/src/apps/files/widgets/file_preview.dart

@ -24,7 +24,7 @@ class FilePreview extends StatelessWidget {
final bool withBackground; final bool withBackground;
@override @override
Widget build(BuildContext context) { Widget build(final BuildContext context) {
final color = this.color ?? Theme.of(context).colorScheme.primary; final color = this.color ?? Theme.of(context).colorScheme.primary;
return SizedBox( return SizedBox(
width: width.toDouble(), width: width.toDouble(),

10
packages/neon/lib/src/apps/news/app.dart

@ -54,23 +54,23 @@ class NewsApp extends AppImplementation<NewsBloc, NewsAppSpecificOptions> {
String id = 'news'; String id = 'news';
@override @override
String nameFromLocalization(AppLocalizations localizations) => localizations.newsName; String nameFromLocalization(final AppLocalizations localizations) => localizations.newsName;
@override @override
NewsAppSpecificOptions buildOptions(Storage storage) => NewsAppSpecificOptions(storage, platform); NewsAppSpecificOptions buildOptions(final Storage storage) => NewsAppSpecificOptions(storage, platform);
@override @override
NewsBloc buildBloc(NextcloudClient client) => NewsBloc( NewsBloc buildBloc(final NextcloudClient client) => NewsBloc(
options, options,
requestManager, requestManager,
client, client,
); );
@override @override
Widget buildPage(BuildContext context, AppsBloc appsBloc) => NewsMainPage( Widget buildPage(final BuildContext context, final AppsBloc appsBloc) => NewsMainPage(
bloc: appsBloc.getAppBloc(this), bloc: appsBloc.getAppBloc(this),
); );
@override @override
BehaviorSubject<int>? getUnreadCounter(AppsBloc appsBloc) => appsBloc.getAppBloc<NewsBloc>(this).unreadCounter; BehaviorSubject<int>? getUnreadCounter(final AppsBloc appsBloc) => appsBloc.getAppBloc<NewsBloc>(this).unreadCounter;
} }

8
packages/neon/lib/src/apps/news/blocs/articles.dart

@ -182,10 +182,10 @@ class NewsArticlesBloc extends $NewsArticlesBloc {
@override @override
void dispose() { void dispose() {
_articlesSubject.close(); unawaited(_articlesSubject.close());
_filterTypeSubject.close(); unawaited(_filterTypeSubject.close());
_articleUpdateController.close(); unawaited(_articleUpdateController.close());
_errorsStreamController.close(); unawaited(_errorsStreamController.close());
super.dispose(); super.dispose();
} }

8
packages/neon/lib/src/apps/news/blocs/news.dart

@ -237,10 +237,10 @@ class NewsBloc extends $NewsBloc {
@override @override
void dispose() { void dispose() {
_foldersSubject.close(); unawaited(_foldersSubject.close());
_feedsSubject.close(); unawaited(_feedsSubject.close());
_errorsStreamController.close(); unawaited(_errorsStreamController.close());
_unreadCounterSubject.close(); unawaited(_unreadCounterSubject.close());
super.dispose(); super.dispose();
} }

4
packages/neon/lib/src/apps/news/dialogs/add_feed.dart

@ -30,6 +30,7 @@ class _NewsAddFeedDialogState extends State<NewsAddFeedDialog> {
void initState() { void initState() {
super.initState(); super.initState();
unawaited(
Clipboard.getData(Clipboard.kTextPlain).then((final clipboardContent) { Clipboard.getData(Clipboard.kTextPlain).then((final clipboardContent) {
if (clipboardContent != null && clipboardContent.text != null) { if (clipboardContent != null && clipboardContent.text != null) {
final uri = Uri.tryParse(clipboardContent.text!); final uri = Uri.tryParse(clipboardContent.text!);
@ -37,7 +38,8 @@ class _NewsAddFeedDialogState extends State<NewsAddFeedDialog> {
controller.text = clipboardContent.text!; controller.text = clipboardContent.text!;
} }
} }
}); }),
);
} }
@override @override

4
packages/neon/lib/src/apps/news/pages/article.dart

@ -37,9 +37,9 @@ class _NewsArticlePageState extends State<NewsArticlePage> {
} }
}); });
WidgetsBinding.instance.addPostFrameCallback((final _) { WidgetsBinding.instance.addPostFrameCallback((final _) async {
if (Provider.of<NeonPlatform>(context, listen: false).canUseWakelock) { if (Provider.of<NeonPlatform>(context, listen: false).canUseWakelock) {
Wakelock.enable(); await Wakelock.enable();
} }
}); });

10
packages/neon/lib/src/apps/notes/app.dart

@ -41,23 +41,23 @@ class NotesApp extends AppImplementation<NotesBloc, NotesAppSpecificOptions> {
String id = 'notes'; String id = 'notes';
@override @override
String nameFromLocalization(AppLocalizations localizations) => localizations.notesName; String nameFromLocalization(final AppLocalizations localizations) => localizations.notesName;
@override @override
NotesAppSpecificOptions buildOptions(Storage storage) => NotesAppSpecificOptions(storage); NotesAppSpecificOptions buildOptions(final Storage storage) => NotesAppSpecificOptions(storage);
@override @override
NotesBloc buildBloc(NextcloudClient client) => NotesBloc( NotesBloc buildBloc(final NextcloudClient client) => NotesBloc(
options, options,
requestManager, requestManager,
client, client,
); );
@override @override
Widget buildPage(BuildContext context, AppsBloc appsBloc) => NotesMainPage( Widget buildPage(final BuildContext context, final AppsBloc appsBloc) => NotesMainPage(
bloc: appsBloc.getAppBloc(this), bloc: appsBloc.getAppBloc(this),
); );
@override @override
BehaviorSubject<int>? getUnreadCounter(AppsBloc appsBloc) => null; BehaviorSubject<int>? getUnreadCounter(final AppsBloc appsBloc) => null;
} }

4
packages/neon/lib/src/apps/notes/blocs/notes.dart

@ -90,8 +90,8 @@ class NotesBloc extends $NotesBloc {
@override @override
void dispose() { void dispose() {
_notesSubject.close(); unawaited(_notesSubject.close());
_errorsStreamController.close(); unawaited(_errorsStreamController.close());
super.dispose(); super.dispose();
} }

8
packages/neon/lib/src/apps/notes/pages/note.dart

@ -72,9 +72,9 @@ class _NotesNotePageState extends State<NotesNotePage> {
} }
}); });
WidgetsBinding.instance.addPostFrameCallback((final _) { WidgetsBinding.instance.addPostFrameCallback((final _) async {
if (Provider.of<NeonPlatform>(context, listen: false).canUseWakelock) { if (Provider.of<NeonPlatform>(context, listen: false).canUseWakelock) {
Wakelock.enable(); await Wakelock.enable();
} }
if (widget.bloc.options.defaultNoteViewTypeOption.value == DefaultNoteViewType.edit || if (widget.bloc.options.defaultNoteViewTypeOption.value == DefaultNoteViewType.edit ||
widget.note.content!.isEmpty) { widget.note.content!.isEmpty) {
@ -189,9 +189,9 @@ class _NotesNotePageState extends State<NotesNotePage> {
) )
: MarkdownBody( : MarkdownBody(
data: _contentController.text, data: _contentController.text,
onTapLink: (final text, final href, final title) { onTapLink: (final text, final href, final title) async {
if (href != null) { if (href != null) {
launchUrlString( await launchUrlString(
href, href,
mode: LaunchMode.externalApplication, mode: LaunchMode.externalApplication,
); );

10
packages/neon/lib/src/apps/notifications/app.dart

@ -21,24 +21,24 @@ class NotificationsApp extends AppImplementation<NotificationsBloc, Notification
String id = 'notifications'; String id = 'notifications';
@override @override
String nameFromLocalization(AppLocalizations localizations) => localizations.notificationsName; String nameFromLocalization(final AppLocalizations localizations) => localizations.notificationsName;
@override @override
NotificationsAppSpecificOptions buildOptions(Storage storage) => NotificationsAppSpecificOptions(storage); NotificationsAppSpecificOptions buildOptions(final Storage storage) => NotificationsAppSpecificOptions(storage);
@override @override
NotificationsBloc buildBloc(NextcloudClient client) => NotificationsBloc( NotificationsBloc buildBloc(final NextcloudClient client) => NotificationsBloc(
options, options,
requestManager, requestManager,
client, client,
); );
@override @override
Widget buildPage(BuildContext context, AppsBloc appsBloc) => NotificationsMainPage( Widget buildPage(final BuildContext context, final AppsBloc appsBloc) => NotificationsMainPage(
bloc: appsBloc.getAppBloc(this), bloc: appsBloc.getAppBloc(this),
); );
@override @override
BehaviorSubject<int>? getUnreadCounter(AppsBloc appsBloc) => BehaviorSubject<int>? getUnreadCounter(final AppsBloc appsBloc) =>
appsBloc.getAppBloc<NotificationsBloc>(this).unreadCounter; appsBloc.getAppBloc<NotificationsBloc>(this).unreadCounter;
} }

6
packages/neon/lib/src/apps/notifications/blocs/notifications.dart

@ -83,9 +83,9 @@ class NotificationsBloc extends $NotificationsBloc {
@override @override
void dispose() { void dispose() {
_notificationsSubject.close(); unawaited(_notificationsSubject.close());
_errorsStreamController.close(); unawaited(_errorsStreamController.close());
_unreadCounterSubject.close(); unawaited(_unreadCounterSubject.close());
super.dispose(); super.dispose();
} }

5
packages/neon/lib/src/apps/notifications/pages/main.dart

@ -23,7 +23,8 @@ class _NotificationsMainPageState extends State<NotificationsMainPage> {
} }
@override @override
Widget build(BuildContext context) => StandardRxResultBuilder<NotificationsBloc, List<NotificationsNotification>>( Widget build(final BuildContext context) =>
StandardRxResultBuilder<NotificationsBloc, List<NotificationsNotification>>(
bloc: widget.bloc, bloc: widget.bloc,
state: (final bloc) => bloc.notifications, state: (final bloc) => bloc.notifications,
builder: ( builder: (
@ -130,7 +131,7 @@ class _NotificationsMainPageState extends State<NotificationsMainPage> {
actions: [ actions: [
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: Colors.red, backgroundColor: Colors.red,
), ),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();

9
packages/neon/lib/src/blocs/accounts.dart

@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'package:neon/src/blocs/user_details.dart'; import 'package:neon/src/blocs/user_details.dart';
@ -106,12 +107,14 @@ class AccountsBloc extends $AccountsBloc {
final lastUsedAccountID = _storage.getString(_keyLastUsedAccount); final lastUsedAccountID = _storage.getString(_keyLastUsedAccount);
_activeAccountSubject.add(accounts.singleWhere((final account) => account.id == lastUsedAccountID)); _activeAccountSubject.add(accounts.singleWhere((final account) => account.id == lastUsedAccountID));
} else { } else {
unawaited(
_globalOptions.initialAccount.stream.first.then((final lastAccount) { _globalOptions.initialAccount.stream.first.then((final lastAccount) {
final matches = accounts.where((final account) => account.id == lastAccount).toList(); final matches = accounts.where((final account) => account.id == lastAccount).toList();
if (matches.isNotEmpty) { if (matches.isNotEmpty) {
_activeAccountSubject.add(matches[0]); _activeAccountSubject.add(matches[0]);
} }
}); }),
);
} }
} }
@ -170,8 +173,8 @@ class AccountsBloc extends $AccountsBloc {
@override @override
void dispose() { void dispose() {
_activeAccountSubject.close(); unawaited(_activeAccountSubject.close());
_accountsSubject.close(); unawaited(_accountsSubject.close());
for (final bloc in _userDetailsBlocs.values) { for (final bloc in _userDetailsBlocs.values) {
bloc.dispose(); bloc.dispose();
} }

10
packages/neon/lib/src/blocs/apps.dart

@ -1,3 +1,5 @@
import 'dart:async';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:neon/src/blocs/accounts.dart'; import 'package:neon/src/blocs/accounts.dart';
import 'package:neon/src/models/account.dart'; import 'package:neon/src/models/account.dart';
@ -65,6 +67,7 @@ class AppsBloc extends $AppsBloc {
_accountsBloc.pushNotificationApp = null; _accountsBloc.pushNotificationApp = null;
} else { } else {
final options = _accountsBloc.getOptions(_account)!..updateApps(appImplementations); final options = _accountsBloc.getOptions(_account)!..updateApps(appImplementations);
unawaited(
options.initialApp.stream.first.then((var initialApp) { options.initialApp.stream.first.then((var initialApp) {
if (initialApp == null) { if (initialApp == null) {
if (appImplementations.where((final a) => a.id == 'files').isNotEmpty) { if (appImplementations.where((final a) => a.id == 'files').isNotEmpty) {
@ -78,7 +81,8 @@ class AppsBloc extends $AppsBloc {
if (!_activeAppSubject.hasValue) { if (!_activeAppSubject.hasValue) {
setActiveApp(initialApp); setActiveApp(initialApp);
} }
}); }),
);
} }
} }
}); });
@ -130,8 +134,8 @@ class AppsBloc extends $AppsBloc {
@override @override
void dispose() { void dispose() {
_appsSubject.close(); unawaited(_appsSubject.close());
_activeAppSubject.close(); unawaited(_activeAppSubject.close());
for (final key in _blocs.keys) { for (final key in _blocs.keys) {
_blocs[key]!.dispose(); _blocs[key]!.dispose();
} }

4
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/models/account.dart';
import 'package:neon/src/neon.dart'; import 'package:neon/src/neon.dart';
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/nextcloud.dart';
@ -48,7 +50,7 @@ class CapabilitiesBloc extends $CapabilitiesBloc {
@override @override
void dispose() { void dispose() {
_capabilitiesSubject.close(); unawaited(_capabilitiesSubject.close());
super.dispose(); super.dispose();
} }

8
packages/neon/lib/src/blocs/login.dart

@ -86,10 +86,10 @@ class LoginBloc extends $LoginBloc {
@override @override
void dispose() { void dispose() {
_cancelPollTimer(); _cancelPollTimer();
_serverURLSubject.close(); unawaited(_serverURLSubject.close());
_serverConnectionStateSubject.close(); unawaited(_serverConnectionStateSubject.close());
_loginFlowInitSubject.close(); unawaited(_loginFlowInitSubject.close());
_loginFlowResultSubject.close(); unawaited(_loginFlowResultSubject.close());
super.dispose(); super.dispose();
} }

6
packages/neon/lib/src/blocs/push_notifications.dart

@ -28,14 +28,14 @@ class PushNotificationsBloc extends $PushNotificationsBloc {
this._platform, this._platform,
) { ) {
if (_platform.canUsePushNotifications) { if (_platform.canUsePushNotifications) {
UnifiedPush.getDistributors().then(_globalOptions.updateDistributors); unawaited(UnifiedPush.getDistributors().then(_globalOptions.updateDistributors));
_globalOptions.pushNotificationsEnabled.stream.listen((final enabled) async { _globalOptions.pushNotificationsEnabled.stream.listen((final enabled) async {
if (enabled != _pushNotificationsEnabled) { if (enabled != _pushNotificationsEnabled) {
_pushNotificationsEnabled = enabled; _pushNotificationsEnabled = enabled;
if (enabled) { if (enabled) {
// We just use a single RSA keypair for all accounts // We just use a single RSA keypair for all accounts
_keypair = PushUtils.loadRSAKeypair(_storage); _keypair = await PushUtils.loadRSAKeypair(_storage);
await _setupUnifiedPush(); await _setupUnifiedPush();
} }
} }
@ -138,7 +138,7 @@ class PushNotificationsBloc extends $PushNotificationsBloc {
@override @override
void dispose() { void dispose() {
_notificationsController.close(); unawaited(_notificationsController.close());
super.dispose(); super.dispose();
} }

4
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/models/account.dart';
import 'package:neon/src/neon.dart'; import 'package:neon/src/neon.dart';
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/nextcloud.dart';
@ -45,7 +47,7 @@ class UserDetailsBloc extends $UserDetailsBloc {
@override @override
void dispose() { void dispose() {
_userDetailsSubject.close(); unawaited(_userDetailsSubject.close());
super.dispose(); super.dispose();
} }

4
packages/neon/lib/src/blocs/user_status.dart

@ -80,8 +80,8 @@ class UserStatusBloc extends $UserStatusBloc {
@override @override
void dispose() { void dispose() {
_cancelTimer(); _cancelTimer();
_activeAccountStreamSubscription.cancel(); unawaited(_activeAccountStreamSubscription.cancel());
_userStatusSubject.close(); unawaited(_userStatusSubject.close());
super.dispose(); super.dispose();
} }

7
packages/neon/lib/src/models/account.dart

@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'package:crypto/crypto.dart'; import 'package:crypto/crypto.dart';
@ -11,7 +12,7 @@ import 'package:settings/settings.dart';
part 'account.g.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() @JsonSerializable()
class Account { class Account {
@ -50,7 +51,7 @@ class Account {
NextcloudClient? _client; NextcloudClient? _client;
void setupClient(PackageInfo packageInfo) { void setupClient(final PackageInfo packageInfo) {
_client ??= NextcloudClient( _client ??= NextcloudClient(
serverURL, serverURL,
username: username, username: username,
@ -115,7 +116,7 @@ class AccountSpecificOptions {
} }
void dispose() { void dispose() {
_appIDsSubject.close(); unawaited(_appIDsSubject.close());
for (final option in options) { for (final option in options) {
option.dispose(); option.dispose();
} }

2
packages/neon/lib/src/models/nextcloud_notification.dart

@ -29,4 +29,4 @@ class NextcloudNotification {
NotificationsPushNotificationDecryptedSubject _fromJsonSubject(final Map<String, dynamic> data) => NotificationsPushNotificationDecryptedSubject _fromJsonSubject(final Map<String, dynamic> data) =>
NotificationsPushNotificationDecryptedSubject.fromJson(data)!; NotificationsPushNotificationDecryptedSubject.fromJson(data)!;
Map<String, dynamic>? _toJsonSubject(NotificationsPushNotificationDecryptedSubject subject) => subject.toJson(); Map<String, dynamic>? _toJsonSubject(final NotificationsPushNotificationDecryptedSubject subject) => subject.toJson();

1
packages/neon/lib/src/neon.dart

@ -4,7 +4,6 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'dart:math'; import 'dart:math';
import 'dart:typed_data';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:crypto/crypto.dart'; import 'package:crypto/crypto.dart';

10
packages/neon/lib/src/pages/home/home.dart

@ -48,7 +48,7 @@ class _HomePageState extends State<HomePage> with tray.TrayListener, WindowListe
_requestManager, _requestManager,
widget.account.client, widget.account.client,
); );
_capabilitiesBloc.capabilities.listen((final result) { _capabilitiesBloc.capabilities.listen((final result) async {
if (result.data != null) { if (result.data != null) {
widget.onThemeChanged(result.data!.capabilities!.theming!); widget.onThemeChanged(result.data!.capabilities!.theming!);
@ -56,14 +56,14 @@ class _HomePageState extends State<HomePage> with tray.TrayListener, WindowListe
if (result is ResultSuccess) { if (result is ResultSuccess) {
const requiredMajorVersion = 24; const requiredMajorVersion = 24;
if (result.data!.version!.major! < requiredMajorVersion) { if (result.data!.version!.major! < requiredMajorVersion) {
showDialog( await showDialog(
context: context, context: context,
builder: (final context) => AlertDialog( builder: (final context) => AlertDialog(
title: Text(AppLocalizations.of(context).errorUnsupportedNextcloudVersion(requiredMajorVersion)), title: Text(AppLocalizations.of(context).errorUnsupportedNextcloudVersion(requiredMajorVersion)),
actions: [ actions: [
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: Colors.red, backgroundColor: Colors.red,
), ),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
@ -200,9 +200,9 @@ class _HomePageState extends State<HomePage> with tray.TrayListener, WindowListe
} }
@override @override
void onTrayMenuItemClick(tray.MenuItem menuItem) { void onTrayMenuItemClick(final tray.MenuItem menuItem) {
if (menuItem.key != null) { if (menuItem.key != null) {
_handleShortcut(menuItem.key!); unawaited(_handleShortcut(menuItem.key!));
} }
} }

4
packages/neon/lib/src/pages/settings/settings.dart

@ -179,8 +179,8 @@ class _SettingsPageState extends State<SettingsPage> {
for (final account in accountsSnapshot.data!) ...[ for (final account in accountsSnapshot.data!) ...[
AccountSettingsTile( AccountSettingsTile(
account: account, account: account,
onTap: () { onTap: () async {
Navigator.of(context).push( await Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute(
builder: (final context) => AccountSpecificSettingsPage( builder: (final context) => AccountSpecificSettingsPage(
bloc: accountsBloc, bloc: accountsBloc,

14
packages/neon/lib/src/utils/app_implementation.dart

@ -15,8 +15,8 @@ List<AppImplementation> getAppImplementations(
abstract class AppImplementation<T extends RxBlocBase, R extends NextcloudAppSpecificOptions> { abstract class AppImplementation<T extends RxBlocBase, R extends NextcloudAppSpecificOptions> {
AppImplementation( AppImplementation(
final SharedPreferences sharedPreferences, final SharedPreferences sharedPreferences,
final this.requestManager, this.requestManager,
final this.platform, this.platform,
) { ) {
final storage = Storage('app-$id', sharedPreferences); final storage = Storage('app-$id', sharedPreferences);
options = buildOptions(storage); options = buildOptions(storage);
@ -26,17 +26,17 @@ abstract class AppImplementation<T extends RxBlocBase, R extends NextcloudAppSpe
final RequestManager requestManager; final RequestManager requestManager;
final NeonPlatform platform; final NeonPlatform platform;
String nameFromLocalization(AppLocalizations localizations); String nameFromLocalization(final AppLocalizations localizations);
String name(BuildContext context) => nameFromLocalization(AppLocalizations.of(context)); String name(final BuildContext context) => nameFromLocalization(AppLocalizations.of(context));
late final R options; late final R options;
R buildOptions(Storage storage); R buildOptions(final Storage storage);
T buildBloc(final NextcloudClient client); T buildBloc(final NextcloudClient client);
BehaviorSubject<int>? getUnreadCounter(AppsBloc appsBloc); BehaviorSubject<int>? getUnreadCounter(final AppsBloc appsBloc);
Widget buildPage(BuildContext context, AppsBloc appsBloc); Widget buildPage(final BuildContext context, final AppsBloc appsBloc);
Widget buildIcon( Widget buildIcon(
final BuildContext context, { final BuildContext context, {

4
packages/neon/lib/src/utils/confirmation_dialog.dart

@ -9,7 +9,7 @@ Future<bool> showConfirmationDialog(final BuildContext context, final String tit
actions: [ actions: [
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: Colors.red, backgroundColor: Colors.red,
), ),
onPressed: () { onPressed: () {
Navigator.of(context).pop(false); Navigator.of(context).pop(false);
@ -18,7 +18,7 @@ Future<bool> showConfirmationDialog(final BuildContext context, final String tit
), ),
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: Colors.green, backgroundColor: Colors.green,
), ),
onPressed: () { onPressed: () {
Navigator.of(context).pop(true); Navigator.of(context).pop(true);

4
packages/neon/lib/src/utils/global_options.dart

@ -77,8 +77,8 @@ class GlobalOptions {
} }
void dispose() { void dispose() {
_accountsIDsSubject.close(); unawaited(_accountsIDsSubject.close());
_themeOLEDAsDarkEnabledSubject.close(); unawaited(_themeOLEDAsDarkEnabledSubject.close());
for (final option in options) { for (final option in options) {
option.dispose(); option.dispose();
} }

11
packages/neon/lib/src/utils/push_utils.dart

@ -1,7 +1,7 @@
part of '../neon.dart'; part of '../neon.dart';
class PushUtils { class PushUtils {
static RSAKeypair loadRSAKeypair(final Storage storage) { static Future<RSAKeypair> loadRSAKeypair(final Storage storage) async {
const keyDevicePrivateKey = 'device-private-key'; const keyDevicePrivateKey = 'device-private-key';
late RSAKeypair keypair; 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) // The key size has to be 2048, other sizes are not accepted by Nextcloud (at the moment at least)
// ignore: avoid_redundant_argument_values // ignore: avoid_redundant_argument_values
keypair = RSAKeypair.fromRandom(keySize: 2048); keypair = RSAKeypair.fromRandom(keySize: 2048);
storage.setString(keyDevicePrivateKey, keypair.privateKey.toPEM()); await storage.setString(keyDevicePrivateKey, keypair.privateKey.toPEM());
} else { } else {
keypair = RSAKeypair(RSAPrivateKey.fromPEM(storage.getString(keyDevicePrivateKey)!)); keypair = RSAKeypair(RSAPrivateKey.fromPEM(storage.getString(keyDevicePrivateKey)!));
} }
@ -47,7 +47,7 @@ class PushUtils {
); );
final sharedPreferences = await SharedPreferences.getInstance(); 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<String, dynamic>; final data = json.decode(utf8.decode(message)) as Map<String, dynamic>;
final notification = NextcloudNotification( final notification = NextcloudNotification(
accountID: instance, accountID: instance,
@ -69,7 +69,8 @@ class PushUtils {
return; 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 localizations = await AppLocalizations.delegate.load(Locale(parts[0], parts.length > 1 ? parts[1] : null));
final platform = await getNeonPlatform(); final platform = await getNeonPlatform();
@ -121,5 +122,5 @@ class PushUtils {
final String instance, final String instance,
final NextcloudNotification notification, 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);
} }

4
packages/neon/lib/src/utils/theme.dart

@ -118,8 +118,8 @@ ThemeData getThemeFromNextcloudTheme(
), ),
elevatedButtonTheme: ElevatedButtonThemeData( elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
onPrimary: onPrimaryColor, foregroundColor: onPrimaryColor,
primary: primaryColor, backgroundColor: primaryColor,
).copyWith( ).copyWith(
elevation: ButtonStyleButton.allOrNull(0), elevation: ButtonStyleButton.allOrNull(0),
), ),

2
packages/neon/lib/src/widgets/image_wrapper.dart

@ -17,7 +17,7 @@ class ImageWrapper extends StatelessWidget {
final BorderRadius? borderRadius; final BorderRadius? borderRadius;
@override @override
Widget build(BuildContext context) => SizedBox( Widget build(final BuildContext context) => SizedBox(
width: width, width: width,
height: height, height: height,
child: DecoratedBox( child: DecoratedBox(

4
packages/nextcloud/analysis_options.yaml

@ -1,9 +1,5 @@
include: package:nit_picking/dart.yaml include: package:nit_picking/dart.yaml
linter:
rules:
prefer_final_parameters: false # Disabled until super.X is no longer complained about in constructors
analyzer: analyzer:
exclude: exclude:
- 'lib/src/clients/common' - 'lib/src/clients/common'

2
packages/nextcloud/lib/src/clients/notifications.dart

@ -26,7 +26,7 @@ class NextcloudNotificationsClient extends DefaultApi {
@override @override
@Deprecated('Use registerDeviceAtServer instead') @Deprecated('Use registerDeviceAtServer instead')
Future<NotificationsPushServerRegistrationResponse?> registerDevice( Future<NotificationsPushServerRegistrationResponse?> registerDevice(
NotificationsPushServerDevice notificationsPushServerDevice, final NotificationsPushServerDevice notificationsPushServerDevice,
) => ) =>
throw Exception('Use registerDeviceAtServer instead'); throw Exception('Use registerDeviceAtServer instead');

4
packages/nextcloud_push_proxy/analysis_options.yaml

@ -1,5 +1 @@
include: package:nit_picking/dart.yaml include: package:nit_picking/dart.yaml
linter:
rules:
prefer_final_parameters: false # Disabled until super.X is no longer complained about in constructors

6
packages/nextcloud_push_proxy/lib/nextcloud_push_proxy.dart

@ -41,7 +41,7 @@ class NextcloudPushProxy {
..post('/notifications', _notificationsHandler) ..post('/notifications', _notificationsHandler)
..get('/health', (final _) async => Response.ok('')); ..get('/health', (final _) async => Response.ok(''));
Future<Response> _devicesHandler(Request request) async { Future<Response> _devicesHandler(final Request request) async {
final data = Uri(query: await request.readAsString()).queryParameters; final data = Uri(query: await request.readAsString()).queryParameters;
_onNewDeviceController.add( _onNewDeviceController.add(
PushProxyDevice( PushProxyDevice(
@ -54,7 +54,7 @@ class NextcloudPushProxy {
return Response.ok(''); return Response.ok('');
} }
Future<Response> _notificationsHandler(Request request) async { Future<Response> _notificationsHandler(final Request request) async {
final data = Uri(query: await request.readAsString()).queryParameters; final data = Uri(query: await request.readAsString()).queryParameters;
for (final notification in data.values) { for (final notification in data.values) {
final notificationData = json.decode(notification) as Map<String, dynamic>; final notificationData = json.decode(notification) as Map<String, dynamic>;
@ -119,7 +119,7 @@ class PushProxyDevice {
required this.userPublicKey, required this.userPublicKey,
}); });
factory PushProxyDevice.fromJson(Map<String, dynamic> data) => PushProxyDevice( factory PushProxyDevice.fromJson(final Map<String, dynamic> data) => PushProxyDevice(
pushToken: data['pushToken'] as String, pushToken: data['pushToken'] as String,
deviceIdentifier: data['deviceIdentifier'] as String, deviceIdentifier: data['deviceIdentifier'] as String,
deviceIdentifierSignature: data['deviceIdentifierSignature'] as String, deviceIdentifierSignature: data['deviceIdentifierSignature'] as String,

4
packages/settings/analysis_options.yaml

@ -1,5 +1 @@
include: package:nit_picking/flutter.yaml include: package:nit_picking/flutter.yaml
linter:
rules:
prefer_final_parameters: false # Disabled until super.X is no longer complained about in constructors

2
packages/settings/lib/settings.dart

@ -1,5 +1,7 @@
library settings; library settings;
import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:intersperse/intersperse.dart'; import 'package:intersperse/intersperse.dart';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';

4
packages/settings/lib/src/options/option.dart

@ -47,8 +47,8 @@ abstract class Option<T> {
} }
void dispose() { void dispose() {
stream.close(); unawaited(stream.close());
enabled.close(); unawaited(enabled.close());
} }
Future set(final T value); Future set(final T value);

4
packages/settings/lib/src/options/select_option.dart

@ -11,6 +11,7 @@ class SelectOption<T> extends Option<T> {
super.enabled, super.enabled,
}) { }) {
stream = BehaviorSubject(); stream = BehaviorSubject();
unawaited(
values.first.then((final vs) async { values.first.then((final vs) async {
final valueStr = storage.getString(key); final valueStr = storage.getString(key);
T? initialValue; T? initialValue;
@ -19,7 +20,8 @@ class SelectOption<T> extends Option<T> {
initialValue = _fromString(vs, valueStr); initialValue = _fromString(vs, valueStr);
} }
stream.add(initialValue ?? await defaultValue.first); stream.add(initialValue ?? await defaultValue.first);
}); }),
);
} }
T? _fromString(final Map<T, LabelBuilder> vs, final String? valueStr) { T? _fromString(final Map<T, LabelBuilder> vs, final String? valueStr) {

4
packages/spec_templates/analysis_options.yaml

@ -1,5 +1 @@
include: package:nit_picking/dart.yaml include: package:nit_picking/dart.yaml
analyzer:
errors:
import_of_legacy_library_into_null_safe: ignore

Loading…
Cancel
Save