diff --git a/lib/data/repositories/quote_repository.dart b/lib/data/repositories/quote_repository.dart index 4fa91cf7e..5406a9800 100644 --- a/lib/data/repositories/quote_repository.dart +++ b/lib/data/repositories/quote_repository.dart @@ -1,4 +1,5 @@ // Dart imports: +import 'dart:async'; import 'dart:convert'; import 'dart:core'; @@ -31,8 +32,9 @@ class QuoteRepository { credentials.token); final InvoiceItemResponse quoteResponse = await (compute( - SerializationUtils.deserializeWith, - [InvoiceItemResponse.serializer, response]) as FutureOr); + SerializationUtils.deserializeWith, + [InvoiceItemResponse.serializer, response]) + as FutureOr); return quoteResponse.data; } @@ -49,8 +51,9 @@ class QuoteRepository { final dynamic response = await webClient.get(url, credentials.token); final InvoiceListResponse quoteResponse = await (compute( - SerializationUtils.deserializeWith, - [InvoiceListResponse.serializer, response]) as FutureOr); + SerializationUtils.deserializeWith, + [InvoiceListResponse.serializer, response]) + as FutureOr); return quoteResponse.data; } diff --git a/lib/data/repositories/recurring_invoice_repository.dart b/lib/data/repositories/recurring_invoice_repository.dart index e03ec69a1..509c498da 100644 --- a/lib/data/repositories/recurring_invoice_repository.dart +++ b/lib/data/repositories/recurring_invoice_repository.dart @@ -51,7 +51,7 @@ class RecurringInvoiceRepository { Future> bulkAction( Credentials credentials, List ids, EntityAction action, - {Map? data}) async { + {Map? data}) async { if (ids.length > kMaxEntitiesPerBulkAction && action.applyMaxLimit) { ids = ids.sublist(0, kMaxEntitiesPerBulkAction); } diff --git a/lib/data/repositories/task_repository.dart b/lib/data/repositories/task_repository.dart index 10d25f060..e3ff9e02c 100644 --- a/lib/data/repositories/task_repository.dart +++ b/lib/data/repositories/task_repository.dart @@ -1,4 +1,5 @@ // Dart imports: +import 'dart:async'; import 'dart:convert'; import 'dart:core'; @@ -29,8 +30,9 @@ class TaskRepository { '${credentials.url}/tasks/$entityId', credentials.token); final TaskItemResponse taskResponse = await (compute( - SerializationUtils.deserializeWith, - [TaskItemResponse.serializer, response]) as FutureOr); + SerializationUtils.deserializeWith, + [TaskItemResponse.serializer, response]) + as FutureOr); return taskResponse.data; } @@ -49,8 +51,9 @@ class TaskRepository { final dynamic response = await webClient.get(url, credentials.token); final TaskListResponse taskResponse = await (compute( - SerializationUtils.deserializeWith, - [TaskListResponse.serializer, response]) as FutureOr); + SerializationUtils.deserializeWith, + [TaskListResponse.serializer, response]) + as FutureOr); return taskResponse.data; } diff --git a/lib/data/repositories/vendor_repository.dart b/lib/data/repositories/vendor_repository.dart index 4667168a4..682ac4a8a 100644 --- a/lib/data/repositories/vendor_repository.dart +++ b/lib/data/repositories/vendor_repository.dart @@ -1,4 +1,5 @@ // Dart imports: +import 'dart:async'; import 'dart:convert'; import 'dart:core'; @@ -31,8 +32,9 @@ class VendorRepository { credentials.token); final VendorItemResponse vendorResponse = await (compute( - SerializationUtils.deserializeWith, - [VendorItemResponse.serializer, response]) as FutureOr); + SerializationUtils.deserializeWith, + [VendorItemResponse.serializer, response]) + as FutureOr); return vendorResponse.data; } @@ -45,8 +47,9 @@ class VendorRepository { final dynamic response = await webClient.get(url, credentials.token); final VendorListResponse vendorResponse = await (compute( - SerializationUtils.deserializeWith, - [VendorListResponse.serializer, response]) as FutureOr); + SerializationUtils.deserializeWith, + [VendorListResponse.serializer, response]) + as FutureOr); return vendorResponse.data; } diff --git a/lib/redux/app/app_middleware.dart b/lib/redux/app/app_middleware.dart index f574c7c27..5aa390ef4 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((value) { + ..future.then(() { AppBuilder.of(navigatorKey.currentContext!)!.rebuild(); store.dispatch(UpdatedSetting()); - } as FutureOr<_> Function(Null)))); + } as FutureOr Function(Null)))); if (uiState!.currentRoute != LoginScreen.route && uiState!.currentRoute.isNotEmpty) { diff --git a/lib/redux/app/app_state.dart b/lib/redux/app/app_state.dart index 772bf965a..ffe71c2cb 100644 --- a/lib/redux/app/app_state.dart +++ b/lib/redux/app/app_state.dart @@ -106,7 +106,9 @@ abstract class AppState implements Built { .map((index) => UserCompanyState(reportErrors)) .toList()), uiState: UIState( - currentRoute: currentRoute, sortFields: prefState?.sortFields), + currentRoute: currentRoute, + sortFields: prefState?.sortFields ?? + BuiltMap()), prefState: prefState ?? PrefState(), ); } @@ -192,7 +194,8 @@ abstract class AppState implements Built { return color.isNotEmpty; } - bool get showReviewApp => !prefState.hideReviewApp && company!.daysActive > 60; + bool get showReviewApp => + !prefState.hideReviewApp && company!.daysActive > 60; bool get showOneYearReviewApp => !prefState.hideOneYearReviewApp && company!.daysActive > 365; @@ -251,7 +254,8 @@ abstract class AppState implements Built { List get unfilteredHistoryList => prefState.companyPrefs[company!.id]!.historyList.toList(); - bool? shouldSelectEntity({EntityType? entityType, List? entityList}) { + bool? shouldSelectEntity( + {EntityType? entityType, List? entityList}) { final entityUIState = getUIState(entityType); if (prefState.isMobile || @@ -962,11 +966,11 @@ abstract class AppState implements Built { : timeago.format(convertTimestampToDate( (userCompanyState.lastUpdated / 1000).round())); - final staticUpdated = - staticState.updatedAt == null || staticState.updatedAt == 0 - ? 'Blank' - : timeago.format( - convertTimestampToDate((staticState.updatedAt! / 1000).round())); + final staticUpdated = staticState.updatedAt == null || + staticState.updatedAt == 0 + ? 'Blank' + : timeago.format( + convertTimestampToDate((staticState.updatedAt! / 1000).round())); final passwordUpdated = authState.lastEnteredPasswordAt == null || authState.lastEnteredPasswordAt == 0 diff --git a/lib/redux/auth/auth_middleware.dart b/lib/redux/auth/auth_middleware.dart index dfdc4ad97..99368e47d 100644 --- a/lib/redux/auth/auth_middleware.dart +++ b/lib/redux/auth/auth_middleware.dart @@ -379,7 +379,7 @@ 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)); @@ -459,9 +459,9 @@ Middleware _purgeData(AuthRepository repository) { store.dispatch(RefreshData( clearData: true, completer: Completer() - ..future.then((value) { + ..future.then(() { action.completer.complete(null); - } as FutureOr<_> Function(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 767361db1..175791879 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((value) { + completer.future.then(() { store.dispatch(RefreshData()); - } as FutureOr<_> Function(Null)); + } as FutureOr Function(Null)); confirmCallback( context: context, callback: (_) { diff --git a/lib/redux/dashboard/dashboard_reducer.dart b/lib/redux/dashboard/dashboard_reducer.dart index 86abaf482..e864d9f41 100644 --- a/lib/redux/dashboard/dashboard_reducer.dart +++ b/lib/redux/dashboard/dashboard_reducer.dart @@ -60,7 +60,7 @@ DashboardUISettings dashboardSettingsReducer( } else if (action.includeTaxes != null) { return state.rebuild((b) => b..includeTaxes = action.includeTaxes); } else if (action.offset != null) { - return state.rebuild((b) => b..offset += action.offset!); + return state.rebuild((b) => b..offset = state.offset + action.offset!); } else if (action.currencyId != null) { return state.rebuild((b) => b..currencyId = action.currencyId); } else if (action.groupBy != null) { diff --git a/lib/redux/dashboard/dashboard_selectors.dart b/lib/redux/dashboard/dashboard_selectors.dart index 96dbcdb72..086f749e4 100644 --- a/lib/redux/dashboard/dashboard_selectors.dart +++ b/lib/redux/dashboard/dashboard_selectors.dart @@ -150,17 +150,18 @@ List _chartInvoices({ outstandingData.entityMap[date] = []; } - totals[STATUS_ACTIVE]![date] += amount; - totals[STATUS_OUTSTANDING]![date] += balance; + totals[STATUS_ACTIVE]![date] = totals[STATUS_ACTIVE]![date]! + amount; + totals[STATUS_OUTSTANDING]![date] = + totals[STATUS_OUTSTANDING]![date]! + balance; activeData.periodTotal += amount; outstandingData.periodTotal += balance; - counts[STATUS_ACTIVE]++; + counts[STATUS_ACTIVE] = counts[STATUS_ACTIVE]! + 1; activeData.entityMap[date]!.add(invoice.id); if (invoice.balance > 0) { - counts[STATUS_OUTSTANDING]++; + counts[STATUS_OUTSTANDING] = counts[STATUS_OUTSTANDING]! + 1; outstandingData.entityMap[date]!.add(invoice.id); } } @@ -275,7 +276,10 @@ List chartQuotes({ } } - if (!quote.isSent || quote.isDeleted! || client.isDeleted! || date.isEmpty) { + if (!quote.isSent || + quote.isDeleted! || + client.isDeleted! || + date.isEmpty) { // skip it } else if (!settings.matchesCurrency(client.currencyId)) { // skip it @@ -312,18 +316,20 @@ List chartQuotes({ unapprovedData.entityMap[date] = []; } - totals[STATUS_ACTIVE]![date] += amount; - counts[STATUS_ACTIVE]++; + totals[STATUS_ACTIVE]![date] = totals[STATUS_ACTIVE]![date]! + amount; + counts[STATUS_ACTIVE] = counts[STATUS_ACTIVE]! + 1; activeData.entityMap[date]!.add(quote.id); if (quote.isApproved) { - totals[STATUS_APPROVED]![date] += amount; - counts[STATUS_APPROVED]++; + totals[STATUS_APPROVED]![date] = + totals[STATUS_APPROVED]![date]! + amount; + counts[STATUS_APPROVED] = counts[STATUS_APPROVED]! + 1; approvedData.entityMap[date]!.add(quote.id); approvedData.periodTotal += amount; } else { - totals[STATUS_UNAPPROVED]![date] += amount; - counts[STATUS_UNAPPROVED]++; + totals[STATUS_UNAPPROVED]![date] = + totals[STATUS_UNAPPROVED]![date]! + amount; + counts[STATUS_UNAPPROVED] = counts[STATUS_UNAPPROVED]! + 1; unapprovedData.entityMap[date]!.add(quote.id); unapprovedData.periodTotal += amount; } @@ -928,12 +934,13 @@ List chartExpenses( return data; } -var memoizedChartExpenses = memo5((BuiltMap currencyMap, - CompanyEntity? company, - DashboardUISettings settings, - BuiltMap invoiceMap, - BuiltMap expenseMap) => - chartExpenses(currencyMap, company!, settings, invoiceMap, expenseMap)); +var memoizedChartExpenses = memo5( + (BuiltMap currencyMap, + CompanyEntity? company, + DashboardUISettings settings, + BuiltMap invoiceMap, + BuiltMap expenseMap) => + chartExpenses(currencyMap, company!, settings, invoiceMap, expenseMap)); var memoizedPreviousChartExpenses = memo5( (BuiltMap currencyMap, diff --git a/lib/ui/invoice/view/invoice_view_overview.dart b/lib/ui/invoice/view/invoice_view_overview.dart index 7c4cb5140..b78caa474 100644 --- a/lib/ui/invoice/view/invoice_view_overview.dart +++ b/lib/ui/invoice/view/invoice_view_overview.dart @@ -189,14 +189,17 @@ class InvoiceOverview extends StatelessWidget { RecurringInvoiceFields.remainingCycles: invoice.remainingCycles == -1 ? localization.endless : '${invoice.remainingCycles}', - RecurringInvoiceFields.autoBill: localization.lookup(invoice.autoBill)! + - ([SettingsEntity.AUTO_BILL_OPT_IN, SettingsEntity.AUTO_BILL_OPT_OUT] - .contains(invoice.autoBill) - ? (' - ' + - (invoice.autoBillEnabled - ? localization.yes - : localization.no)) - : ''), + RecurringInvoiceFields.autoBill: + localization.lookup(invoice.autoBill)! + + ([ + SettingsEntity.AUTO_BILL_OPT_IN, + SettingsEntity.AUTO_BILL_OPT_OUT + ].contains(invoice.autoBill) + ? (' - ' + + (invoice.autoBillEnabled + ? localization.yes + : localization.no)) + : ''), InvoiceFields.dueDate: invoice.dueDateDays == 'terms' ? localization.paymentTerm : invoice.dueDateDays == 'on_receipt' @@ -320,12 +323,12 @@ class InvoiceOverview extends StatelessWidget { paymentMap.entries.forEach((entry) { final payment = entry.value!; final paymentable = entry.key; - String? amount = formatNumber( + String amount = formatNumber( paymentable.amount, context, clientId: invoice.isPurchaseOrder ? null : client!.id, vendorId: invoice.isPurchaseOrder ? invoice.vendorId : null, - ); + )!; if (paymentable.amount != payment.amount) { amount += '/' + formatNumber( @@ -350,12 +353,12 @@ class InvoiceOverview extends StatelessWidget { creditMap.entries.forEach((entry) { final credit = entry.value!; final paymentable = entry.key; - String? amount = formatNumber( + String amount = formatNumber( paymentable.amount, context, clientId: invoice.isPurchaseOrder ? null : client!.id, vendorId: invoice.isPurchaseOrder ? invoice.vendorId : null, - ); + )!; if (paymentable.amount != credit.amount) { amount += '/' + formatNumber(