Browse Source

refactor: enable analyzer option strict-inference

Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/809/head
Nikolas Rimikis 1 year ago
parent
commit
d6c75b4219
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 2
      packages/dynamite/dynamite/lib/src/helpers/type_result.dart
  2. 2
      packages/dynamite/dynamite_runtime/test/content_string_test.dart
  3. 2
      packages/neon/neon/lib/src/pages/home.dart
  4. 4
      packages/neon/neon/lib/src/utils/global.dart
  5. 2
      packages/neon/neon/lib/src/utils/global_popups.dart
  6. 4
      packages/neon/neon/lib/src/utils/push_utils.dart
  7. 2
      packages/neon/neon/lib/src/widgets/account_switcher_button.dart
  8. 2
      packages/neon/neon/lib/src/widgets/app_bar.dart
  9. 2
      packages/neon/neon/test/result_test.dart
  10. 2
      packages/neon/neon/test/settings_export_test.dart
  11. 2
      packages/neon/neon/test/stream_listenable_test.dart
  12. 2
      packages/neon/neon/test/timer_bloc_test.dart
  13. 2
      packages/neon/neon_files/lib/dialogs/choose_folder.dart
  14. 2
      packages/neon/neon_files/lib/pages/main.dart
  15. 2
      packages/neon/neon_files/lib/utils/task.dart
  16. 2
      packages/neon/neon_files/lib/widgets/actions.dart
  17. 2
      packages/neon/neon_files/lib/widgets/browser_view.dart
  18. 4
      packages/neon/neon_news/lib/widgets/articles_view.dart
  19. 6
      packages/neon/neon_news/lib/widgets/feeds_view.dart
  20. 2
      packages/neon/neon_news/lib/widgets/folders_view.dart
  21. 2
      packages/neon/neon_notes/lib/widgets/categories_view.dart
  22. 2
      packages/neon/neon_notes/lib/widgets/category_select.dart
  23. 2
      packages/neon/neon_notes/lib/widgets/notes_view.dart
  24. 2
      packages/neon/neon_notifications/lib/pages/main.dart
  25. 1
      packages/neon_lints/lib/src/base.yaml
  26. 1
      packages/neon_lints/lint_maker.yaml
  27. 8
      packages/nextcloud/lib/src/api/dashboard.openapi.dart
  28. 8
      packages/nextcloud/lib/src/api/provisioning_api.openapi.dart
  29. 8
      packages/nextcloud/lib/src/webdav/client.dart
  30. 2
      packages/nextcloud/test/helper.dart

2
packages/dynamite/dynamite/lib/src/helpers/type_result.dart

@ -6,7 +6,7 @@ String valueToEscapedValue(final TypeResult result, final String value) {
return "'$value'";
}
if (result is TypeResultList) {
return 'const $value';
return 'const <${result.subType.name}>$value';
}
if (result is TypeResultEnum) {
return '${result.name}.${toDartName(value)}';

2
packages/dynamite/dynamite_runtime/test/content_string_test.dart

@ -1,4 +1,4 @@
// ignore_for_file: avoid_redundant_argument_values
// ignore_for_file: avoid_redundant_argument_values, inference_failure_on_instance_creation
import 'dart:convert';

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

@ -99,7 +99,7 @@ class _HomePageState extends State<HomePage> {
Future<void> _showProblem(final String title) async {
final colorScheme = Theme.of(context).colorScheme;
await showDialog(
await showDialog<void>(
context: context,
builder: (final context) => AlertDialog(
title: Text(title),

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

@ -5,6 +5,6 @@ import 'package:neon/src/models/push_notification.dart';
class Global {
const Global._();
static Function(String accountID)? onPushNotificationReceived;
static Function(PushNotification notification)? onPushNotificationClicked;
static Future<void> Function(String accountID)? onPushNotificationReceived;
static Future<void> Function(PushNotification notification)? onPushNotificationClicked;
}

2
packages/neon/neon/lib/src/utils/global_popups.dart

@ -72,7 +72,7 @@ class GlobalPopups {
return;
}
await showDialog(
await showDialog<void>(
context: _context,
builder: (final context) => AlertDialog(
title: Text(AppLocalizations.of(context).nextPushSupported),

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

@ -89,7 +89,7 @@ class PushUtils {
await localNotificationsPlugin.cancel(_getNotificationID(instance, pushNotification));
} else if (pushNotification.subject.deleteAll ?? false) {
await localNotificationsPlugin.cancelAll();
Global.onPushNotificationReceived?.call(instance);
await Global.onPushNotificationReceived?.call(instance);
} else if (pushNotification.type == 'background') {
debugPrint('Got unknown background notification ${json.encode(pushNotification.toJson())}');
} else {
@ -174,7 +174,7 @@ class PushUtils {
}
}
Global.onPushNotificationReceived?.call(instance);
await Global.onPushNotificationReceived?.call(instance);
}
}

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

@ -28,7 +28,7 @@ class AccountSwitcherButton extends StatelessWidget {
title: Text(AppLocalizations.of(context).settingsAccountManage),
onTap: () {
Navigator.of(context).pop();
const SettingsRoute(initialCategory: SettingsCategories.accounts).push(context);
const SettingsRoute(initialCategory: SettingsCategories.accounts).push<void>(context);
},
),
],

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

@ -231,7 +231,7 @@ class _NotificationIconButtonState extends State<NotificationIconButton> {
);
await Navigator.of(context).push(
MaterialPageRoute(
MaterialPageRoute<void>(
builder: (final context) => Provider<NotificationsBlocInterface>(
create: (final context) => app.getBloc(_account),
child: page,

2
packages/neon/neon/test/result_test.dart

@ -1,3 +1,5 @@
// ignore_for_file: inference_failure_on_instance_creation
import 'package:neon/blocs.dart';
import 'package:test/test.dart';

2
packages/neon/neon/test/settings_export_test.dart

@ -1,4 +1,4 @@
// ignore_for_file: avoid_implementing_value_types
// ignore_for_file: avoid_implementing_value_types, inference_failure_on_collection_literal
import 'dart:convert';
import 'dart:typed_data';

2
packages/neon/neon/test/stream_listenable_test.dart

@ -1,4 +1,4 @@
// ignore_for_file: unreachable_from_main
// ignore_for_file: unreachable_from_main, inference_failure_on_instance_creation
import 'dart:async';

2
packages/neon/neon/test/timer_bloc_test.dart

@ -1,3 +1,5 @@
// ignore_for_file: inference_failure_on_instance_creation
import 'package:neon/blocs.dart';
import 'package:test/test.dart';

2
packages/neon/neon_files/lib/dialogs/choose_folder.dart

@ -49,7 +49,7 @@ class FilesChooseFolderDialog extends StatelessWidget {
child: Text(AppLocalizations.of(context).folderCreate),
),
ElevatedButton(
onPressed: !(const ListEquality().equals(originalPath, pathSnapshot.data))
onPressed: !(const ListEquality<String>().equals(originalPath, pathSnapshot.data))
? () => Navigator.of(context).pop(pathSnapshot.data)
: null,
child: Text(AppLocalizations.of(context).folderChoose),

2
packages/neon/neon_files/lib/pages/main.dart

@ -30,7 +30,7 @@ class _FilesMainPageState extends State<FilesMainPage> {
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
await showDialog(
await showDialog<void>(
context: context,
builder: (final context) => FilesChooseCreateDialog(
bloc: bloc,

2
packages/neon/neon_files/lib/utils/task.dart

@ -1,3 +1,5 @@
// ignore_for_file: unnecessary_lambdas
part of '../neon_files.dart';
sealed class FilesTask {

2
packages/neon/neon_files/lib/widgets/actions.dart

@ -24,7 +24,7 @@ class FileActions extends StatelessWidget {
}
case FilesFileAction.details:
await Navigator.of(context).push(
MaterialPageRoute(
MaterialPageRoute<void>(
builder: (final context) => FilesDetailsPage(
bloc: bloc,
details: details,

2
packages/neon/neon_files/lib/widgets/browser_view.dart

@ -177,7 +177,7 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
),
);
bool _pathMatchesFile(final List<String> path, final String name) => const ListEquality().equals(
bool _pathMatchesFile(final List<String> path, final String name) => const ListEquality<String>().equals(
[...widget.bloc.path.value, name],
path,
);

4
packages/neon/neon_news/lib/widgets/articles_view.dart

@ -188,7 +188,7 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
if ((viewType == ArticleViewType.direct || article.url == null) && bodyData != null) {
await Navigator.of(context).push(
MaterialPageRoute(
MaterialPageRoute<void>(
builder: (final context) => NewsArticlePage(
bloc: NewsArticleBloc(
widget.bloc,
@ -205,7 +205,7 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
article.url != null &&
NeonPlatform.instance.canUseWebView) {
await Navigator.of(context).push(
MaterialPageRoute(
MaterialPageRoute<void>(
builder: (final context) => NewsArticlePage(
bloc: NewsArticleBloc(
widget.bloc,

6
packages/neon/neon_news/lib/widgets/feeds_view.dart

@ -64,7 +64,7 @@ class NewsFeedsView extends StatelessWidget {
if (feed.updateErrorCount > 0) ...[
IconButton(
onPressed: () async {
await showDialog(
await showDialog<void>(
context: context,
builder: (final context) => NewsFeedUpdateErrorDialog(
feed: feed,
@ -105,7 +105,7 @@ class NewsFeedsView extends StatelessWidget {
onSelected: (final action) async {
switch (action) {
case NewsFeedAction.showURL:
await showDialog(
await showDialog<void>(
context: context,
builder: (final context) => NewsFeedShowURLDialog(
feed: feed,
@ -159,7 +159,7 @@ class NewsFeedsView extends StatelessWidget {
},
onTap: () async {
await Navigator.of(context).push(
MaterialPageRoute(
MaterialPageRoute<void>(
builder: (final context) => NewsFeedPage(
bloc: bloc,
feed: feed,

2
packages/neon/neon_news/lib/widgets/folders_view.dart

@ -114,7 +114,7 @@ class NewsFoldersView extends StatelessWidget {
},
onTap: () async {
await Navigator.of(context).push(
MaterialPageRoute(
MaterialPageRoute<void>(
builder: (final context) => NewsFolderPage(
bloc: bloc,
folder: folder,

2
packages/neon/neon_notes/lib/widgets/categories_view.dart

@ -52,7 +52,7 @@ class NotesCategoriesView extends StatelessWidget {
: const SizedBox.square(dimension: largeIconSize),
onTap: () async {
await Navigator.of(context).push(
MaterialPageRoute(
MaterialPageRoute<void>(
builder: (final context) => NotesCategoryPage(
bloc: bloc,
category: category,

2
packages/neon/neon_notes/lib/widgets/category_select.dart

@ -21,7 +21,7 @@ class NotesCategorySelect extends StatelessWidget {
final List<String> categories;
final String? initialValue;
final Function(String category) onChanged;
final ValueChanged<String> onChanged;
final VoidCallback onSubmitted;
@override

2
packages/neon/neon_notes/lib/widgets/notes_view.dart

@ -76,7 +76,7 @@ class NotesView extends StatelessWidget {
),
onTap: () async {
await Navigator.of(context).push(
MaterialPageRoute(
MaterialPageRoute<void>(
builder: (final context) => NotesNotePage(
bloc: NotesNoteBloc(
bloc,

2
packages/neon/neon_notifications/lib/pages/main.dart

@ -95,7 +95,7 @@ class _NotificationsMainPageState extends State<NotificationsMainPage> {
} else {
final colorScheme = Theme.of(context).colorScheme;
await showDialog(
await showDialog<void>(
context: context,
builder: (final context) => AlertDialog(
title: Text(AppLocalizations.of(context).notificationAppNotImplementedYet),

1
packages/neon_lints/lib/src/base.yaml

@ -1,6 +1,7 @@
analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
flutter_style_todos: ignore

1
packages/neon_lints/lint_maker.yaml

@ -19,6 +19,7 @@ dart:
analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
flutter_style_todos: ignore

8
packages/nextcloud/lib/src/api/dashboard.openapi.dart

@ -120,7 +120,7 @@ class DashboardDashboardApiClient {
Future<DashboardDashboardApiGetWidgetItemsResponseApplicationJson> getWidgetItems({
final ContentString<BuiltMap<String, String>>? sinceIds,
final int limit = 7,
final List<String> widgets = const [],
final List<String> widgets = const <String>[],
final String oCSAPIRequest = 'true',
}) async {
const path = '/ocs/v2.php/apps/dashboard/api/v1/widget-items';
@ -153,7 +153,7 @@ class DashboardDashboardApiClient {
if (limit != 7) {
queryParameters['limit'] = limit.toString();
}
if (widgets != const []) {
if (widgets != const <String>[]) {
queryParameters['widgets[]'] = widgets.map((final e) => e);
}
headers['OCS-APIRequest'] = oCSAPIRequest;
@ -176,7 +176,7 @@ class DashboardDashboardApiClient {
Future<DashboardDashboardApiGetWidgetItemsV2ResponseApplicationJson> getWidgetItemsV2({
final ContentString<BuiltMap<String, String>>? sinceIds,
final int limit = 7,
final List<String> widgets = const [],
final List<String> widgets = const <String>[],
final String oCSAPIRequest = 'true',
}) async {
const path = '/ocs/v2.php/apps/dashboard/api/v2/widget-items';
@ -209,7 +209,7 @@ class DashboardDashboardApiClient {
if (limit != 7) {
queryParameters['limit'] = limit.toString();
}
if (widgets != const []) {
if (widgets != const <String>[]) {
queryParameters['widgets[]'] = widgets.map((final e) => e);
}
headers['OCS-APIRequest'] = oCSAPIRequest;

8
packages/nextcloud/lib/src/api/provisioning_api.openapi.dart

@ -1185,8 +1185,8 @@ class ProvisioningApiUsersClient {
final String password = '',
final String displayName = '',
final String email = '',
final List<String> groups = const [],
final List<String> subadmin = const [],
final List<String> groups = const <String>[],
final List<String> subadmin = const <String>[],
final String quota = '',
final String language = '',
final String? manager,
@ -1221,10 +1221,10 @@ class ProvisioningApiUsersClient {
if (email != '') {
queryParameters['email'] = email;
}
if (groups != const []) {
if (groups != const <String>[]) {
queryParameters['groups[]'] = groups.map((final e) => e);
}
if (subadmin != const []) {
if (subadmin != const <String>[]) {
queryParameters['subadmin[]'] = subadmin.map((final e) => e);
}
if (quota != '') {

8
packages/nextcloud/lib/src/webdav/client.dart

@ -160,7 +160,7 @@ class WebDavClient {
final DateTime? lastModified,
final DateTime? created,
final int? contentLength,
final Function(double progres)? onProgress,
final void Function(double progres)? onProgress,
}) async {
var uploaded = 0;
return _send(
@ -193,7 +193,7 @@ class WebDavClient {
final Uri path, {
final DateTime? lastModified,
final DateTime? created,
final Function(double progres)? onProgress,
final void Function(double progres)? onProgress,
}) async =>
putStream(
file.openRead().cast<Uint8List>(),
@ -217,12 +217,12 @@ class WebDavClient {
Future<void> getFile(
final Uri path,
final File file, {
final Function(double progress)? onProgress,
final void Function(double progress)? onProgress,
}) async {
final sink = file.openWrite();
final response = await getStream(path);
if (response.contentLength > 0) {
final completer = Completer();
final completer = Completer<void>();
var downloaded = 0;
response.listen((final chunk) async {

2
packages/nextcloud/test/helper.dart

@ -1,3 +1,5 @@
// ignore_for_file: inference_failure_on_instance_creation
import 'dart:async';
import 'dart:convert';
import 'dart:io';

Loading…
Cancel
Save