diff --git a/lib/redux/app/app_middleware.dart b/lib/redux/app/app_middleware.dart index 5aa390ef4..e4f1d0d72 100644 --- a/lib/redux/app/app_middleware.dart +++ b/lib/redux/app/app_middleware.dart @@ -234,10 +234,10 @@ Middleware _createLoadState( store.dispatch(LoadStateSuccess(appState)); store.dispatch(RefreshData( completer: Completer() - ..future.then(() { + ..future.then((_) { AppBuilder.of(navigatorKey.currentContext!)!.rebuild(); store.dispatch(UpdatedSetting()); - } as FutureOr Function(Null)))); + }))); if (uiState!.currentRoute != LoginScreen.route && uiState!.currentRoute.isNotEmpty) { diff --git a/lib/redux/auth/auth_middleware.dart b/lib/redux/auth/auth_middleware.dart index 99368e47d..d7085c079 100644 --- a/lib/redux/auth/auth_middleware.dart +++ b/lib/redux/auth/auth_middleware.dart @@ -379,12 +379,12 @@ Middleware _createCompany(AuthRepository repository) { store.dispatch(RefreshData( allCompanies: true, completer: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch(SelectCompany(companyIndex: state.companies.length)); store.dispatch(ViewDashboard(force: true)); action!.completer!.complete(); - } as FutureOr Function(Null)), + }), )); }); @@ -459,9 +459,9 @@ Middleware _purgeData(AuthRepository repository) { store.dispatch(RefreshData( clearData: true, completer: Completer() - ..future.then(() { + ..future.then((_) { action.completer.complete(null); - } as FutureOr Function(Null)))); + }))); }).catchError((Object error) { store.dispatch(PurgeDataFailure(error)); action.completer.completeError(error); diff --git a/lib/redux/company_gateway/company_gateway_actions.dart b/lib/redux/company_gateway/company_gateway_actions.dart index da4a61895..5f3c230fa 100644 --- a/lib/redux/company_gateway/company_gateway_actions.dart +++ b/lib/redux/company_gateway/company_gateway_actions.dart @@ -309,9 +309,9 @@ void handleCompanyGatewayAction(BuildContext? context, case EntityAction.disconnect: final completer = snackBarCompleter(context, localization!.disconnectedGateway); - completer.future.then(() { + completer.future.then((_) { store.dispatch(RefreshData()); - } as FutureOr Function(Null)); + }); confirmCallback( context: context, callback: (_) { diff --git a/lib/redux/document/document_actions.dart b/lib/redux/document/document_actions.dart index 174cbe4cf..c6cca11cf 100644 --- a/lib/redux/document/document_actions.dart +++ b/lib/redux/document/document_actions.dart @@ -483,82 +483,67 @@ void handleDocumentAction( context, AppLocalization.of(context)!.deletedDocument); switch (document!.parentType) { case EntityType.client: - completer.future.then((() => store.dispatch( - LoadClient(clientId: document.parentId))) - as FutureOr Function(Null)); + completer.future.then(((_) => store + .dispatch(LoadClient(clientId: document.parentId)))); break; case EntityType.credit: - completer.future.then((() => store.dispatch( - LoadCredit(creditId: document.parentId))) - as FutureOr Function(Null)); + completer.future.then(((_) => store + .dispatch(LoadCredit(creditId: document.parentId)))); break; case EntityType.expense: - completer.future.then((() => store.dispatch( - LoadExpense(expenseId: document.parentId))) - as FutureOr Function(Null)); + completer.future.then(((_) => store.dispatch( + LoadExpense(expenseId: document.parentId)))); break; case EntityType.group: - completer.future.then((() => store - .dispatch(LoadGroup(groupId: document.parentId))) - as FutureOr Function(Null)); + completer.future.then(((_) => store + .dispatch(LoadGroup(groupId: document.parentId)))); break; case EntityType.invoice: - completer.future.then((() => store.dispatch( - LoadInvoice(invoiceId: document.parentId))) - as FutureOr Function(Null)); + completer.future.then(((_) => store.dispatch( + LoadInvoice(invoiceId: document.parentId)))); break; case EntityType.product: - completer.future.then((() => store.dispatch( - LoadProduct(productId: document.parentId))) - as FutureOr Function(Null)); + completer.future.then(((_) => store.dispatch( + LoadProduct(productId: document.parentId)))); break; case EntityType.project: - completer.future.then((() => store.dispatch( - LoadProject(projectId: document.parentId))) - as FutureOr Function(Null)); + completer.future.then(((_) => store.dispatch( + LoadProject(projectId: document.parentId)))); break; case EntityType.purchaseOrder: - completer.future.then((() => store.dispatch( - LoadPurchaseOrder( - purchaseOrderId: document.parentId))) - as FutureOr Function(Null)); + completer.future.then(((_) => store.dispatch( + LoadPurchaseOrder( + purchaseOrderId: document.parentId)))); break; case EntityType.quote: - completer.future.then((() => store - .dispatch(LoadQuote(quoteId: document.parentId))) - as FutureOr Function(Null)); + completer.future.then(((_) => store + .dispatch(LoadQuote(quoteId: document.parentId)))); break; case EntityType.recurringExpense: - completer.future.then((() => store.dispatch( - LoadRecurringExpense( - recurringExpenseId: document.parentId))) - as FutureOr Function(Null)); + completer.future.then(((_) => store.dispatch( + LoadRecurringExpense( + recurringExpenseId: document.parentId)))); break; case EntityType.recurringInvoice: - completer.future.then((() => store.dispatch( - LoadRecurringInvoice( - recurringInvoiceId: document.parentId))) - as FutureOr Function(Null)); + completer.future.then(((_) => store.dispatch( + LoadRecurringInvoice( + recurringInvoiceId: document.parentId)))); break; case EntityType.task: - completer.future.then((() => store - .dispatch(LoadTask(taskId: document.parentId))) - as FutureOr Function(Null)); + completer.future.then(((_) => + store.dispatch(LoadTask(taskId: document.parentId)))); break; case EntityType.vendor: - completer.future.then((() => store.dispatch( - LoadVendor(vendorId: document.parentId))) - as FutureOr Function(Null)); + completer.future.then(((_) => store + .dispatch(LoadVendor(vendorId: document.parentId)))); break; default: - completer.future.then((() => - store.dispatch(RefreshData())) - as FutureOr Function(Null)); + completer.future + .then(((_) => store.dispatch(RefreshData()))); } - completer.future.then((() => - store.dispatch(RefreshData())) - as FutureOr Function(Null)); + completer.future + .then(((_) => store.dispatch(RefreshData()))); store.dispatch(DeleteDocumentRequest( completer: completer, documentIds: [document.id], diff --git a/lib/ui/app/desktop_session_timeout.dart b/lib/ui/app/desktop_session_timeout.dart index 2295df7de..cd113a4b6 100644 --- a/lib/ui/app/desktop_session_timeout.dart +++ b/lib/ui/app/desktop_session_timeout.dart @@ -90,11 +90,11 @@ class _DesktopSessionTimeoutState extends State { onPressed: () { final store = StoreProvider.of(context); final completer = Completer(); - completer.future.then(() { + completer.future.then((_) { setState(() { _isWarned = false; }); - } as FutureOr Function(Null)); + }); store.dispatch(RefreshData(completer: completer)); }, child: Text( diff --git a/lib/ui/app/dialogs/health_check_dialog.dart b/lib/ui/app/dialogs/health_check_dialog.dart index e34e98f6e..c412172ae 100644 --- a/lib/ui/app/dialogs/health_check_dialog.dart +++ b/lib/ui/app/dialogs/health_check_dialog.dart @@ -88,9 +88,9 @@ class _HealthCheckDialogState extends State { webClient.get(url, credentials.token).then((dynamic response) { store.dispatch(RefreshData( completer: Completer() - ..future.then(() { + ..future.then((_) { runCheck(); - } as FutureOr Function(Null)))); + }))); }).catchError((dynamic error) { showErrorDialog(message: error); }); diff --git a/lib/ui/app/history_drawer.dart b/lib/ui/app/history_drawer.dart index 35440be06..7b10f78d0 100644 --- a/lib/ui/app/history_drawer.dart +++ b/lib/ui/app/history_drawer.dart @@ -261,9 +261,9 @@ class _HistoryListTileState extends State { entities: [entity], completer: state.prefState.isHistoryFloated ? (Completer() - ..future.then(() { + ..future.then((_) { Navigator.pop(context); - } as FutureOr Function(Null))) + })) : null, ); }, diff --git a/lib/ui/app/menu_drawer_vm.dart b/lib/ui/app/menu_drawer_vm.dart index 58f246c7c..ba8b6b9be 100644 --- a/lib/ui/app/menu_drawer_vm.dart +++ b/lib/ui/app/menu_drawer_vm.dart @@ -140,9 +140,9 @@ class MenuDrawerVM { final completer = snackBarCompleter( context, AppLocalization.of(context)!.addedCompany, shouldPop: true) - ..future.then(() { + ..future.then((_) { AppBuilder.of(navigatorKey.currentContext!)!.rebuild(); - } as FutureOr Function(Null)); + }); store .dispatch(AddCompany(context: context, completer: completer)); diff --git a/lib/ui/app/tables/entity_list.dart b/lib/ui/app/tables/entity_list.dart index 49b19df96..5292e42b5 100644 --- a/lib/ui/app/tables/entity_list.dart +++ b/lib/ui/app/tables/entity_list.dart @@ -470,9 +470,8 @@ class _EntityListState extends State { entities: entities, multiselect: true, completer: Completer() - ..future.then((() => - widget.onClearMultiselect()) - as FutureOr Function(Null)), + ..future.then( + ((_) => widget.onClearMultiselect())), ); }, onCancelPressed: (_) => widget.onClearMultiselect(), diff --git a/lib/ui/auth/login_view.dart b/lib/ui/auth/login_view.dart index ab4931cb3..88f4def43 100644 --- a/lib/ui/auth/login_view.dart +++ b/lib/ui/auth/login_view.dart @@ -184,13 +184,11 @@ class _LoginState extends State { } final Completer completer = Completer(); - completer.future - .then(() { + completer.future.then((_) { setState(() { _loginError = ''; }); - } as FutureOr Function(Null)) - .catchError((Object error) { + }).catchError((Object error) { setState(() { _buttonController.reset(); _loginError = error.toString(); diff --git a/lib/ui/auth/login_vm.dart b/lib/ui/auth/login_vm.dart index 2510ba069..0abf97c7a 100644 --- a/lib/ui/auth/login_vm.dart +++ b/lib/ui/auth/login_vm.dart @@ -184,8 +184,8 @@ class LoginVM { provider: UserEntity.OAUTH_PROVIDER_GOOGLE, oneTimePassword: oneTimePassword, )); - completer.future.then((() => _handleLogin(context: context)) - as FutureOr Function(Null)); + completer.future + .then(((_) => _handleLogin(context: context))); } }); if (!signedIn) { @@ -215,9 +215,8 @@ class LoginVM { accessToken: accessToken, provider: UserEntity.OAUTH_PROVIDER_GOOGLE, )); - completer.future.then((() => - _handleLogin(context: context, isSignUp: true)) - as FutureOr Function(Null)); + completer.future.then( + ((_) => _handleLogin(context: context, isSignUp: true))); } }); if (!signedIn) { @@ -249,8 +248,8 @@ class LoginVM { provider: UserEntity.OAUTH_PROVIDER_MICROSOFT, oneTimePassword: oneTimePassword, )); - completer.future.then((() => _handleLogin(context: context)) - as FutureOr Function(Null)); + completer.future + .then(((_) => _handleLogin(context: context))); }, (dynamic error) { completer.completeError(error); }); @@ -270,9 +269,8 @@ class LoginVM { provider: UserEntity.OAUTH_PROVIDER_MICROSOFT, accessToken: accessToken, )); - completer.future.then((() => - _handleLogin(context: context, isSignUp: true)) - as FutureOr Function(Null)); + completer.future.then( + ((_) => _handleLogin(context: context, isSignUp: true))); }, (dynamic error) { completer.completeError(error); }); @@ -311,8 +309,7 @@ class LoginVM { authCode: credentials.authorizationCode, idToken: credentials.identityToken, )); - completer.future.then((() => _handleLogin(context: context)) - as FutureOr Function(Null)); + completer.future.then(((_) => _handleLogin(context: context))); } catch (error) { completer.completeError(error); print('## onAppleLoginPressed: $error'); @@ -340,9 +337,8 @@ class LoginVM { firstName: credentials.givenName, lastName: credentials.familyName, )); - completer.future.then((() => - _handleLogin(context: context, isSignUp: true)) - as FutureOr Function(Null)); + completer.future.then( + ((_) => _handleLogin(context: context, isSignUp: true))); } catch (error) { completer.completeError(error); print('## onAppleSignUpPressed: $error'); @@ -363,9 +359,8 @@ class LoginVM { email: email.trim(), password: password.trim(), )); - completer.future.then((() => - _handleLogin(context: context, isSignUp: true)) - as FutureOr Function(Null)); + completer.future.then( + ((_) => _handleLogin(context: context, isSignUp: true))); }, onRecoverPressed: ( BuildContext context, diff --git a/lib/ui/company_gateway/company_gateway_screen.dart b/lib/ui/company_gateway/company_gateway_screen.dart index 179623fae..1e8d0fd26 100644 --- a/lib/ui/company_gateway/company_gateway_screen.dart +++ b/lib/ui/company_gateway/company_gateway_screen.dart @@ -72,9 +72,8 @@ class CompanyGatewayScreen extends StatelessWidget { entities: companyGateways, multiselect: true, completer: Completer() - ..future.then((() => store - .dispatch(ClearCompanyGatewayMultiselect())) - as FutureOr Function(Null)), + ..future.then(((_) => + store.dispatch(ClearCompanyGatewayMultiselect()))), ); }, onCancelPressed: (context) => diff --git a/lib/ui/credit/credit_email_vm.dart b/lib/ui/credit/credit_email_vm.dart index 7d5ed1706..9b745e2c5 100644 --- a/lib/ui/credit/credit_email_vm.dart +++ b/lib/ui/credit/credit_email_vm.dart @@ -92,9 +92,9 @@ class EmailCreditVM extends EmailEntityVM { context, AppLocalization.of(context)!.emailedCredit, shouldPop: isMobile(context)); if (!isMobile(context)) { - completer.future.then(() { + completer.future.then((_) { viewEntity(entity: credit); - } as FutureOr Function(Null)); + }); } store.dispatch(EmailCreditRequest( completer: completer, diff --git a/lib/ui/credit/edit/credit_edit_details_vm.dart b/lib/ui/credit/edit/credit_edit_details_vm.dart index 94297e2f2..423ddf65d 100644 --- a/lib/ui/credit/edit/credit_edit_details_vm.dart +++ b/lib/ui/credit/edit/credit_edit_details_vm.dart @@ -103,9 +103,9 @@ class CreditEditDetailsVM extends EntityEditDetailsVM { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch(UpdateCurrentRoute(CreditEditScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity client) { store.dispatch(UpdateCurrentRoute(CreditEditScreen.route)); }); diff --git a/lib/ui/expense/edit/expense_edit_vm.dart b/lib/ui/expense/edit/expense_edit_vm.dart index d1e9d8ff8..4b9e8cf27 100644 --- a/lib/ui/expense/edit/expense_edit_vm.dart +++ b/lib/ui/expense/edit/expense_edit_vm.dart @@ -120,9 +120,9 @@ class ExpenseEditVM extends AbstractExpenseEditVM { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch(UpdateCurrentRoute(ExpenseEditScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity client) { store.dispatch(UpdateCurrentRoute(ExpenseEditScreen.route)); }); @@ -134,9 +134,9 @@ class ExpenseEditVM extends AbstractExpenseEditVM { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch(UpdateCurrentRoute(ExpenseEditScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity expense) { store.dispatch(UpdateCurrentRoute(ExpenseEditScreen.route)); }); diff --git a/lib/ui/invoice/edit/invoice_edit_details_vm.dart b/lib/ui/invoice/edit/invoice_edit_details_vm.dart index 3e8391cee..d686978c3 100644 --- a/lib/ui/invoice/edit/invoice_edit_details_vm.dart +++ b/lib/ui/invoice/edit/invoice_edit_details_vm.dart @@ -131,9 +131,9 @@ class InvoiceEditDetailsVM extends EntityEditDetailsVM { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch(UpdateCurrentRoute(InvoiceEditScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity client) { store.dispatch(UpdateCurrentRoute(InvoiceEditScreen.route)); }); diff --git a/lib/ui/invoice/invoice_email_vm.dart b/lib/ui/invoice/invoice_email_vm.dart index b26f43986..f6306ae8d 100644 --- a/lib/ui/invoice/invoice_email_vm.dart +++ b/lib/ui/invoice/invoice_email_vm.dart @@ -113,9 +113,9 @@ class EmailInvoiceVM extends EmailEntityVM { context, AppLocalization.of(context)!.emailedInvoice, shouldPop: isMobile(context)); if (!isMobile(context)) { - completer.future.then(() { + completer.future.then((_) { viewEntity(entity: invoice); - } as FutureOr Function(Null)); + }); } store.dispatch(EmailInvoiceRequest( completer: completer, diff --git a/lib/ui/project/edit/project_edit_vm.dart b/lib/ui/project/edit/project_edit_vm.dart index b6d2d2fa4..1287cb1aa 100644 --- a/lib/ui/project/edit/project_edit_vm.dart +++ b/lib/ui/project/edit/project_edit_vm.dart @@ -88,9 +88,9 @@ class ProjectEditVM { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch(UpdateCurrentRoute(ProjectEditScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity client) { store.dispatch(UpdateCurrentRoute(ProjectEditScreen.route)); }); diff --git a/lib/ui/purchase_order/edit/purchase_order_edit_details_vm.dart b/lib/ui/purchase_order/edit/purchase_order_edit_details_vm.dart index 36affb5ca..1791c1afb 100644 --- a/lib/ui/purchase_order/edit/purchase_order_edit_details_vm.dart +++ b/lib/ui/purchase_order/edit/purchase_order_edit_details_vm.dart @@ -102,10 +102,10 @@ class PurchaseOrderEditDetailsVM extends EntityEditDetailsVM { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch( UpdateCurrentRoute(PurchaseOrderEditScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity client) { store.dispatch(UpdateCurrentRoute(PurchaseOrderEditScreen.route)); }); diff --git a/lib/ui/purchase_order/purchase_order_email_vm.dart b/lib/ui/purchase_order/purchase_order_email_vm.dart index 3dbed5b93..d3d66e817 100644 --- a/lib/ui/purchase_order/purchase_order_email_vm.dart +++ b/lib/ui/purchase_order/purchase_order_email_vm.dart @@ -90,9 +90,9 @@ class EmailPurchaseOrderVM extends EmailEntityVM { context, AppLocalization.of(context)!.emailedPurchaseOrder, shouldPop: isMobile(context)); if (!isMobile(context)) { - completer.future.then(() { + completer.future.then((_) { viewEntity(entity: purchaseOrder); - } as FutureOr Function(Null)); + }); } store.dispatch(EmailPurchaseOrderRequest( completer: completer, diff --git a/lib/ui/quote/edit/quote_edit_details_vm.dart b/lib/ui/quote/edit/quote_edit_details_vm.dart index c0213fa18..034d93337 100644 --- a/lib/ui/quote/edit/quote_edit_details_vm.dart +++ b/lib/ui/quote/edit/quote_edit_details_vm.dart @@ -102,9 +102,9 @@ class QuoteEditDetailsVM extends EntityEditDetailsVM { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch(UpdateCurrentRoute(QuoteEditScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity client) { store.dispatch(UpdateCurrentRoute(QuoteEditScreen.route)); }); diff --git a/lib/ui/quote/quote_email_vm.dart b/lib/ui/quote/quote_email_vm.dart index 4fdcffafb..9453128ce 100644 --- a/lib/ui/quote/quote_email_vm.dart +++ b/lib/ui/quote/quote_email_vm.dart @@ -89,9 +89,9 @@ class EmailQuoteVM extends EmailEntityVM { context, AppLocalization.of(context)!.emailedQuote, shouldPop: isMobile(context)); if (!isMobile(context)) { - completer.future.then(() { + completer.future.then((_) { viewEntity(entity: quote); - } as FutureOr Function(Null)); + }); } store.dispatch(EmailQuoteRequest( completer: completer, diff --git a/lib/ui/recurring_expense/edit/recurring_expense_edit_vm.dart b/lib/ui/recurring_expense/edit/recurring_expense_edit_vm.dart index c0326b0e8..a640fac81 100644 --- a/lib/ui/recurring_expense/edit/recurring_expense_edit_vm.dart +++ b/lib/ui/recurring_expense/edit/recurring_expense_edit_vm.dart @@ -90,10 +90,10 @@ class RecurringExpenseEditVM extends AbstractExpenseEditVM { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch( UpdateCurrentRoute(RecurringExpenseEditScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity client) { store.dispatch(UpdateCurrentRoute(RecurringExpenseEditScreen.route)); }); @@ -105,10 +105,10 @@ class RecurringExpenseEditVM extends AbstractExpenseEditVM { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch( UpdateCurrentRoute(RecurringExpenseEditScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity expense) { store.dispatch(UpdateCurrentRoute(RecurringExpenseEditScreen.route)); }); diff --git a/lib/ui/recurring_invoice/edit/recurring_invoice_edit_details_vm.dart b/lib/ui/recurring_invoice/edit/recurring_invoice_edit_details_vm.dart index 433685a00..555b881f3 100644 --- a/lib/ui/recurring_invoice/edit/recurring_invoice_edit_details_vm.dart +++ b/lib/ui/recurring_invoice/edit/recurring_invoice_edit_details_vm.dart @@ -105,10 +105,10 @@ class RecurringInvoiceEditDetailsVM extends EntityEditDetailsVM { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch( UpdateCurrentRoute(RecurringInvoiceEditScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity client) { store.dispatch(UpdateCurrentRoute(RecurringInvoiceEditScreen.route)); }); diff --git a/lib/ui/settings/account_management_vm.dart b/lib/ui/settings/account_management_vm.dart index ef089df80..61947a3fb 100644 --- a/lib/ui/settings/account_management_vm.dart +++ b/lib/ui/settings/account_management_vm.dart @@ -73,8 +73,7 @@ class AccountManagementVM { final companyLength = state.companies.length; final deleteCompleter = Completer() - ..future - .then(() { + ..future.then((_) { final context = navigatorKey.currentContext; final state = store.state; if (companyLength == 1) { @@ -87,7 +86,7 @@ class AccountManagementVM { final index = selectedCompanyIndex == 0 ? 1 : 0; store.dispatch(SelectCompany(companyIndex: index)); final refreshCompleter = Completer() - ..future.then(() { + ..future.then((_) { store.dispatch(SelectCompany(companyIndex: 0)); store.dispatch(ViewDashboard()); AppBuilder.of(navigatorKey.currentContext!)!.rebuild(); @@ -95,12 +94,11 @@ class AccountManagementVM { if (Navigator.of(context!).canPop()) { Navigator.of(context).pop(); } - } as FutureOr Function(Null)); + }); store.dispatch( RefreshData(clearData: true, completer: refreshCompleter)); } - } as FutureOr Function(Null)) - .catchError((Object error) { + }).catchError((Object error) { if (Navigator.of(navigatorKey.currentContext!).canPop()) { Navigator.of(navigatorKey.currentContext!).pop(); } diff --git a/lib/ui/settings/client_portal_vm.dart b/lib/ui/settings/client_portal_vm.dart index 39a07c3fa..f5e4d4d7d 100644 --- a/lib/ui/settings/client_portal_vm.dart +++ b/lib/ui/settings/client_portal_vm.dart @@ -82,10 +82,10 @@ class ClientPortalVM { final oldSubdomain = state.company!.subdomain; final newSubdomain = settingsUIState.company.subdomain; if (oldSubdomain != newSubdomain) { - completer.future.then(() { + completer.future.then((_) { showRefreshDataDialog( context: navigatorKey.currentContext!); - } as FutureOr Function(Null)); + }); } store.dispatch(SaveCompanyRequest( diff --git a/lib/ui/settings/invoice_design_vm.dart b/lib/ui/settings/invoice_design_vm.dart index aa284e0fa..c6d010003 100644 --- a/lib/ui/settings/invoice_design_vm.dart +++ b/lib/ui/settings/invoice_design_vm.dart @@ -83,7 +83,7 @@ class InvoiceDesignVM { case EntityType.company: final completer = snackBarCompleter( context, AppLocalization.of(context)!.savedSettings) - ..future.then(() { + ..future.then((_) { final webClient = WebClient(); final credentials = state.credentials; final url = '${credentials.url}/designs/set/default'; @@ -106,7 +106,7 @@ class InvoiceDesignVM { showErrorDialog(message: '$error'); }); }); - } as FutureOr Function(Null)); + }); store.dispatch(SaveCompanyRequest( completer: completer, company: settingsUIState.company)); break; diff --git a/lib/ui/settings/localization_vm.dart b/lib/ui/settings/localization_vm.dart index 4dc35ac91..f33177ee1 100644 --- a/lib/ui/settings/localization_vm.dart +++ b/lib/ui/settings/localization_vm.dart @@ -75,14 +75,14 @@ class LocalizationSettingsVM { final appBuilder = AppBuilder.of(context); final completer = snackBarCompleter( context, AppLocalization.of(context)!.savedSettings) - ..future.then(() { + ..future.then((_) { appBuilder!.rebuild(); store.dispatch(RefreshData( includeStatic: true, completer: Completer() ..future .then((dynamic value) => appBuilder.rebuild()))); - } as FutureOr Function(Null)); + }); store.dispatch(SaveCompanyRequest( completer: completer, company: settingsUIState.company)); break; diff --git a/lib/ui/settings/settings_wizard.dart b/lib/ui/settings/settings_wizard.dart index a7f4cf5ce..1a9ef856c 100644 --- a/lib/ui/settings/settings_wizard.dart +++ b/lib/ui/settings/settings_wizard.dart @@ -146,18 +146,15 @@ class _SettingsWizardState extends State { callback: (password, idToken) { final localization = AppLocalization.of(context); final completer = Completer(); - completer.future - .then(() { + completer.future.then((_) { final toastCompleter = snackBarCompleter(context, localization!.savedSettings); - toastCompleter.future - .then(() { + toastCompleter.future.then((_) { setState(() { _isSaving = false; _showLogo = true; }); - } as FutureOr Function(Null)) - .catchError((Object error) { + }).catchError((Object error) { setState(() { _isSaving = false; }); @@ -174,8 +171,7 @@ class _SettingsWizardState extends State { ), ), ); - } as FutureOr Function(Null)) - .catchError((Object error) { + }).catchError((Object error) { setState(() => _isSaving = false); }); diff --git a/lib/ui/settings/templates_and_reminders_vm.dart b/lib/ui/settings/templates_and_reminders_vm.dart index 5ea565c09..525ec422c 100644 --- a/lib/ui/settings/templates_and_reminders_vm.dart +++ b/lib/ui/settings/templates_and_reminders_vm.dart @@ -96,8 +96,7 @@ class TemplatesAndRemindersVM { case EntityType.company: final completer = snackBarCompleter( context, AppLocalization.of(context)!.savedSettings); - completer.future.then( - (() => callback()) as FutureOr Function(Null)); + completer.future.then(((_) => callback())); store.dispatch(SaveCompanyRequest( completer: completer, company: settingsUIState.company)); break; diff --git a/lib/ui/settings/user_details_vm.dart b/lib/ui/settings/user_details_vm.dart index 6c25294a9..f3209596d 100644 --- a/lib/ui/settings/user_details_vm.dart +++ b/lib/ui/settings/user_details_vm.dart @@ -176,9 +176,9 @@ class UserDetailsVM { callback: (password, idToken) { final completer = snackBarCompleter(context, AppLocalization.of(context)!.disconnectedGoogle); - completer.future.then(() { + completer.future.then((_) { GoogleOAuth.disconnect(); - } as FutureOr Function(Null)); + }); store.dispatch( DisconnecOAuthUserRequest( user: state.user, @@ -315,7 +315,7 @@ class UserDetailsVM { final appBuilder = AppBuilder.of(context); final origUserSettings = state.userCompany!.settings; - completer.future.then(() async { + completer.future.then((_) async { final newUserSettings = store.state.userCompany!.settings!; if (origUserSettings!.includeDeletedClients != newUserSettings.includeDeletedClients || @@ -338,7 +338,7 @@ class UserDetailsVM { } appBuilder!.rebuild(); - } as FutureOr Function(Null)); + }); confirmCallback( context: context, diff --git a/lib/ui/task/edit/task_edit_details_vm.dart b/lib/ui/task/edit/task_edit_details_vm.dart index a77856f2c..c9fdfd728 100644 --- a/lib/ui/task/edit/task_edit_details_vm.dart +++ b/lib/ui/task/edit/task_edit_details_vm.dart @@ -82,9 +82,9 @@ class TaskEditDetailsVM { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch(UpdateCurrentRoute(TaskEditDetailsScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity client) { store.dispatch(UpdateCurrentRoute(TaskEditDetailsScreen.route)); }); @@ -107,9 +107,9 @@ class TaskEditDetailsVM { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch(UpdateCurrentRoute(TaskEditDetailsScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity client) { store.dispatch(UpdateCurrentRoute(TaskEditDetailsScreen.route)); }); diff --git a/lib/ui/task_status/task_status_screen.dart b/lib/ui/task_status/task_status_screen.dart index 463a05981..9a9fa049a 100644 --- a/lib/ui/task_status/task_status_screen.dart +++ b/lib/ui/task_status/task_status_screen.dart @@ -78,9 +78,8 @@ class TaskStatusScreen extends StatelessWidget { entities: taskStatusIds, multiselect: true, completer: Completer() - ..future.then((() => - store.dispatch(ClearTaskStatusMultiselect())) - as FutureOr Function(Null)), + ..future.then( + ((_) => store.dispatch(ClearTaskStatusMultiselect()))), ); }, label: localization!.actions, diff --git a/lib/ui/transaction/edit/transaction_edit_vm.dart b/lib/ui/transaction/edit/transaction_edit_vm.dart index a39a26e19..be1a8c48d 100644 --- a/lib/ui/transaction/edit/transaction_edit_vm.dart +++ b/lib/ui/transaction/edit/transaction_edit_vm.dart @@ -110,9 +110,9 @@ class TransactionEditVM { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch(UpdateCurrentRoute(TransactionEditScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity client) { store.dispatch(UpdateCurrentRoute(TransactionEditScreen.route)); }); diff --git a/lib/ui/transaction/view/transaction_view.dart b/lib/ui/transaction/view/transaction_view.dart index e7fac79df..c8375c9de 100644 --- a/lib/ui/transaction/view/transaction_view.dart +++ b/lib/ui/transaction/view/transaction_view.dart @@ -1109,10 +1109,10 @@ class _MatchWithdrawalsState extends State<_MatchWithdrawals> { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch(UpdateCurrentRoute( TransactionScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity vendor) { store.dispatch(SaveTransactionSuccess(transaction .rebuild((b) => b..pendingVendorId = vendor.id))); @@ -1193,10 +1193,10 @@ class _MatchWithdrawalsState extends State<_MatchWithdrawals> { force: true, completer: completer, cancelCompleter: Completer() - ..future.then(() { + ..future.then((_) { store.dispatch(UpdateCurrentRoute( TransactionScreen.route)); - } as FutureOr Function(Null))); + })); completer.future.then((SelectableEntity category) { store.dispatch(SaveTransactionSuccess( transaction.rebuild( diff --git a/lib/ui/transaction/view/transaction_view_vm.dart b/lib/ui/transaction/view/transaction_view_vm.dart index b92749972..a690142ed 100644 --- a/lib/ui/transaction/view/transaction_view_vm.dart +++ b/lib/ui/transaction/view/transaction_view_vm.dart @@ -118,14 +118,14 @@ class TransactionViewVM { ConvertTransactionsToExpensesRequest( snackBarCompleter( context, AppLocalization.of(context)!.convertedTransaction) - ..future.then(() { + ..future.then((_) { if (state.transactionListState.isInMultiselect()) { store.dispatch(ClearTransactionMultiselect()); if (store.state.prefState.isPreviewVisible) { store.dispatch(TogglePreviewSidebar()); } } - } as FutureOr Function(Null)), + }), transactionIds, vendorId, categoryId, diff --git a/lib/utils/completers.dart b/lib/utils/completers.dart index 050417e23..f574c07d4 100644 --- a/lib/utils/completers.dart +++ b/lib/utils/completers.dart @@ -46,11 +46,9 @@ Completer snackBarCompleter( Completer popCompleter(BuildContext context, dynamic result) { final Completer completer = Completer(); - completer.future - .then(() { + completer.future.then((_) { Navigator.of(context).pop(result); - } as FutureOr Function(Null)) - .catchError((Object error) { + }).catchError((Object error) { showDialog( context: navigatorKey.currentContext!, builder: (BuildContext context) {