diff --git a/packages/neon/neon/lib/src/bloc/bloc.dart b/packages/neon/neon/lib/src/bloc/bloc.dart index d1907585..72629c47 100644 --- a/packages/neon/neon/lib/src/bloc/bloc.dart +++ b/packages/neon/neon/lib/src/bloc/bloc.dart @@ -25,9 +25,9 @@ abstract class InteractiveBloc extends Bloc { // ignore: avoid_void_async void wrapAction( - final Future Function() call, { + final AsyncCallback call, { final bool disableTimeout = false, - final Future Function()? refresh, + final AsyncCallback? refresh, }) async { try { if (disableTimeout) { diff --git a/packages/neon/neon/lib/src/settings/widgets/account_settings_tile.dart b/packages/neon/neon/lib/src/settings/widgets/account_settings_tile.dart index ae62dbe2..1779e1ed 100644 --- a/packages/neon/neon/lib/src/settings/widgets/account_settings_tile.dart +++ b/packages/neon/neon/lib/src/settings/widgets/account_settings_tile.dart @@ -17,7 +17,7 @@ class AccountSettingsTile extends SettingsTile { final Account account; final Color? color; final Widget? trailing; - final VoidCallback? onTap; + final GestureTapCallback? onTap; @override Widget build(final BuildContext context) => NeonAccountTile( diff --git a/packages/neon/neon/lib/src/settings/widgets/custom_settings_tile.dart b/packages/neon/neon/lib/src/settings/widgets/custom_settings_tile.dart index f042bcc6..6e216943 100644 --- a/packages/neon/neon/lib/src/settings/widgets/custom_settings_tile.dart +++ b/packages/neon/neon/lib/src/settings/widgets/custom_settings_tile.dart @@ -17,7 +17,7 @@ class CustomSettingsTile extends SettingsTile { final Widget? subtitle; final Widget? leading; final Widget? trailing; - final Function()? onTap; + final GestureTapCallback? onTap; @override Widget build(final BuildContext context) => ListTile( diff --git a/packages/neon/neon/lib/src/utils/global_options.dart b/packages/neon/neon/lib/src/utils/global_options.dart index 62fe0e9d..eac4bccc 100644 --- a/packages/neon/neon/lib/src/utils/global_options.dart +++ b/packages/neon/neon/lib/src/utils/global_options.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:meta/meta.dart'; import 'package:neon/l10n/localizations.dart'; import 'package:neon/src/models/account.dart'; +import 'package:neon/src/models/label_builder.dart'; import 'package:neon/src/settings/models/option.dart'; import 'package:neon/src/settings/models/options_collection.dart'; import 'package:neon/src/settings/models/select_option.dart'; @@ -51,7 +52,7 @@ class GlobalOptions extends OptionsCollection { final PackageInfo _packageInfo; - late final _distributorsMap = { + late final _distributorsMap = { _packageInfo.packageName: (final context) => AppLocalizations.of(context).globalOptionsPushNotificationsDistributorFirebaseEmbedded, 'com.github.gotify.up': (final context) => diff --git a/packages/neon/neon/lib/src/utils/request_manager.dart b/packages/neon/neon/lib/src/utils/request_manager.dart index 08725131..ec1b96ed 100644 --- a/packages/neon/neon/lib/src/utils/request_manager.dart +++ b/packages/neon/neon/lib/src/utils/request_manager.dart @@ -10,6 +10,11 @@ import 'package:rxdart/rxdart.dart'; import 'package:sqflite/sqflite.dart'; import 'package:xml/xml.dart' as xml; +typedef UnwrapCallback = T Function(R); +typedef SerializeCallback = String Function(T); +typedef DeserializeCallback = T Function(String); +typedef NextcloudApiCallback = Future Function(); + class RequestManager { RequestManager(); @@ -33,8 +38,8 @@ class RequestManager { final String clientID, final String k, final BehaviorSubject> subject, - final Future Function() call, - final T Function(R) unwrap, { + final NextcloudApiCallback call, + final UnwrapCallback unwrap, { final bool disableTimeout = false, final bool emitEmptyCache = false, }) async => @@ -55,8 +60,8 @@ class RequestManager { final String clientID, final String k, final BehaviorSubject> subject, - final Future Function() call, - final T Function(WebDavMultistatus) unwrap, { + final NextcloudApiCallback call, + final UnwrapCallback unwrap, { final bool disableTimeout = false, final bool emitEmptyCache = false, }) async => @@ -77,10 +82,10 @@ class RequestManager { final String clientID, final String k, final BehaviorSubject> subject, - final Future Function() call, - final T Function(R) unwrap, - final String Function(R) serialize, - final R Function(String) deserialize, + final NextcloudApiCallback call, + final UnwrapCallback unwrap, + final SerializeCallback serialize, + final DeserializeCallback deserialize, final bool disableTimeout, final bool emitEmptyCache, final int retries, @@ -150,8 +155,8 @@ class RequestManager { Future _emitCached( final String key, final BehaviorSubject> subject, - final T Function(R) unwrap, - final R Function(String) deserialize, + final UnwrapCallback unwrap, + final DeserializeCallback deserialize, final bool emitEmptyCache, final bool loading, final Object? error, @@ -180,7 +185,7 @@ class RequestManager { } Future timeout( - final Future Function() call, + final NextcloudApiCallback call, ) => call().timeout(const Duration(seconds: 30)); } diff --git a/packages/neon/neon/lib/src/widgets/account_tile.dart b/packages/neon/neon/lib/src/widgets/account_tile.dart index bffa171f..6361e938 100644 --- a/packages/neon/neon/lib/src/widgets/account_tile.dart +++ b/packages/neon/neon/lib/src/widgets/account_tile.dart @@ -25,7 +25,7 @@ class NeonAccountTile extends StatelessWidget { final Account account; final Color? color; final Widget? trailing; - final VoidCallback? onTap; + final GestureTapCallback? onTap; final Color? textColor; final bool dense; final bool showStatus; diff --git a/packages/neon/neon/lib/src/widgets/exception.dart b/packages/neon/neon/lib/src/widgets/exception.dart index fdd6460c..c181b34f 100644 --- a/packages/neon/neon/lib/src/widgets/exception.dart +++ b/packages/neon/neon/lib/src/widgets/exception.dart @@ -22,7 +22,7 @@ class NeonException extends StatelessWidget { }); final dynamic exception; - final Function() onRetry; + final VoidCallback onRetry; final bool onlyIcon; final double? iconSize; final Color? color; diff --git a/packages/neon/neon/lib/src/widgets/list_view.dart b/packages/neon/neon/lib/src/widgets/list_view.dart index b043b458..c33aae02 100644 --- a/packages/neon/neon/lib/src/widgets/list_view.dart +++ b/packages/neon/neon/lib/src/widgets/list_view.dart @@ -19,7 +19,7 @@ class NeonListView extends StatelessWidget { final Iterable? items; final bool isLoading; final dynamic error; - final Future Function() onRefresh; + final RefreshCallback onRefresh; final Widget Function(BuildContext, T data) builder; final String? scrollKey; final bool withFloatingActionButton; diff --git a/packages/neon/neon_files/lib/options.dart b/packages/neon/neon_files/lib/options.dart index 620b3857..6dfff087 100644 --- a/packages/neon/neon_files/lib/options.dart +++ b/packages/neon/neon_files/lib/options.dart @@ -86,7 +86,7 @@ class FilesAppSpecificOptions extends NextcloudAppOptions { }, ); - late final _sizeWarningValues = { + late final _sizeWarningValues = { null: (final context) => AppLocalizations.of(context).optionsSizeWarningDisabled, for (final i in [ 1, diff --git a/packages/neon/neon_news/lib/blocs/article.dart b/packages/neon/neon_news/lib/blocs/article.dart index 289c51a6..a87e5c65 100644 --- a/packages/neon/neon_news/lib/blocs/article.dart +++ b/packages/neon/neon_news/lib/blocs/article.dart @@ -78,7 +78,7 @@ class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents, }); } - void _wrapArticleAction(final Future Function() call) => wrapAction( + void _wrapArticleAction(final AsyncCallback call) => wrapAction( call, refresh: () async { await _newsArticlesBloc.refresh(); diff --git a/packages/neon/neon_news/lib/neon_news.dart b/packages/neon/neon_news/lib/neon_news.dart index 9cf83e7c..63b766bf 100644 --- a/packages/neon/neon_news/lib/neon_news.dart +++ b/packages/neon/neon_news/lib/neon_news.dart @@ -2,6 +2,7 @@ library neon_news; import 'dart:async'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_html/flutter_html.dart'; diff --git a/packages/neon/neon_news/lib/widgets/folder_select.dart b/packages/neon/neon_news/lib/widgets/folder_select.dart index e8dd9c38..569d3dd7 100644 --- a/packages/neon/neon_news/lib/widgets/folder_select.dart +++ b/packages/neon/neon_news/lib/widgets/folder_select.dart @@ -9,7 +9,7 @@ class NewsFolderSelect extends StatelessWidget { }); final List folders; - final void Function(NewsFolder?) onChanged; + final ValueChanged onChanged; final NewsFolder? value; @override diff --git a/packages/neon/neon_notes/lib/widgets/category_select.dart b/packages/neon/neon_notes/lib/widgets/category_select.dart index ca5a8f54..d153f6a3 100644 --- a/packages/neon/neon_notes/lib/widgets/category_select.dart +++ b/packages/neon/neon_notes/lib/widgets/category_select.dart @@ -22,7 +22,7 @@ class NotesCategorySelect extends StatelessWidget { final List categories; final String? initialValue; final Function(String category) onChanged; - final Function() onSubmitted; + final VoidCallback onSubmitted; @override Widget build(final BuildContext context) => Autocomplete(