Null safety
This commit is contained in:
parent
f5e6fe9cfe
commit
3b435fd70b
|
|
@ -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<dynamic, dynamic>(
|
||||
SerializationUtils.deserializeWith,
|
||||
<dynamic>[InvoiceItemResponse.serializer, response]) as FutureOr<InvoiceItemResponse>);
|
||||
SerializationUtils.deserializeWith,
|
||||
<dynamic>[InvoiceItemResponse.serializer, response])
|
||||
as FutureOr<InvoiceItemResponse>);
|
||||
|
||||
return quoteResponse.data;
|
||||
}
|
||||
|
|
@ -49,8 +51,9 @@ class QuoteRepository {
|
|||
final dynamic response = await webClient.get(url, credentials.token);
|
||||
|
||||
final InvoiceListResponse quoteResponse = await (compute<dynamic, dynamic>(
|
||||
SerializationUtils.deserializeWith,
|
||||
<dynamic>[InvoiceListResponse.serializer, response]) as FutureOr<InvoiceListResponse>);
|
||||
SerializationUtils.deserializeWith,
|
||||
<dynamic>[InvoiceListResponse.serializer, response])
|
||||
as FutureOr<InvoiceListResponse>);
|
||||
|
||||
return quoteResponse.data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class RecurringInvoiceRepository {
|
|||
|
||||
Future<List<InvoiceEntity>> bulkAction(
|
||||
Credentials credentials, List<String> ids, EntityAction action,
|
||||
{Map<String, Object?>? data}) async {
|
||||
{Map<String, Object>? data}) async {
|
||||
if (ids.length > kMaxEntitiesPerBulkAction && action.applyMaxLimit) {
|
||||
ids = ids.sublist(0, kMaxEntitiesPerBulkAction);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<dynamic, dynamic>(
|
||||
SerializationUtils.deserializeWith,
|
||||
<dynamic>[TaskItemResponse.serializer, response]) as FutureOr<TaskItemResponse>);
|
||||
SerializationUtils.deserializeWith,
|
||||
<dynamic>[TaskItemResponse.serializer, response])
|
||||
as FutureOr<TaskItemResponse>);
|
||||
|
||||
return taskResponse.data;
|
||||
}
|
||||
|
|
@ -49,8 +51,9 @@ class TaskRepository {
|
|||
final dynamic response = await webClient.get(url, credentials.token);
|
||||
|
||||
final TaskListResponse taskResponse = await (compute<dynamic, dynamic>(
|
||||
SerializationUtils.deserializeWith,
|
||||
<dynamic>[TaskListResponse.serializer, response]) as FutureOr<TaskListResponse>);
|
||||
SerializationUtils.deserializeWith,
|
||||
<dynamic>[TaskListResponse.serializer, response])
|
||||
as FutureOr<TaskListResponse>);
|
||||
|
||||
return taskResponse.data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<dynamic, dynamic>(
|
||||
SerializationUtils.deserializeWith,
|
||||
<dynamic>[VendorItemResponse.serializer, response]) as FutureOr<VendorItemResponse>);
|
||||
SerializationUtils.deserializeWith,
|
||||
<dynamic>[VendorItemResponse.serializer, response])
|
||||
as FutureOr<VendorItemResponse>);
|
||||
|
||||
return vendorResponse.data;
|
||||
}
|
||||
|
|
@ -45,8 +47,9 @@ class VendorRepository {
|
|||
final dynamic response = await webClient.get(url, credentials.token);
|
||||
|
||||
final VendorListResponse vendorResponse = await (compute<dynamic, dynamic>(
|
||||
SerializationUtils.deserializeWith,
|
||||
<dynamic>[VendorListResponse.serializer, response]) as FutureOr<VendorListResponse>);
|
||||
SerializationUtils.deserializeWith,
|
||||
<dynamic>[VendorListResponse.serializer, response])
|
||||
as FutureOr<VendorListResponse>);
|
||||
|
||||
return vendorResponse.data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -234,10 +234,10 @@ Middleware<AppState> _createLoadState(
|
|||
store.dispatch(LoadStateSuccess(appState));
|
||||
store.dispatch(RefreshData(
|
||||
completer: Completer<Null>()
|
||||
..future.then((value) {
|
||||
..future.then<Null>(() {
|
||||
AppBuilder.of(navigatorKey.currentContext!)!.rebuild();
|
||||
store.dispatch(UpdatedSetting());
|
||||
} as FutureOr<_> Function(Null))));
|
||||
} as FutureOr<Null> Function(Null))));
|
||||
|
||||
if (uiState!.currentRoute != LoginScreen.route &&
|
||||
uiState!.currentRoute.isNotEmpty) {
|
||||
|
|
|
|||
|
|
@ -106,7 +106,9 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
.map((index) => UserCompanyState(reportErrors))
|
||||
.toList()),
|
||||
uiState: UIState(
|
||||
currentRoute: currentRoute, sortFields: prefState?.sortFields),
|
||||
currentRoute: currentRoute,
|
||||
sortFields: prefState?.sortFields ??
|
||||
BuiltMap<EntityType, PrefStateSortField>()),
|
||||
prefState: prefState ?? PrefState(),
|
||||
);
|
||||
}
|
||||
|
|
@ -192,7 +194,8 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
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<AppState, AppStateBuilder> {
|
|||
List<HistoryRecord> get unfilteredHistoryList =>
|
||||
prefState.companyPrefs[company!.id]!.historyList.toList();
|
||||
|
||||
bool? shouldSelectEntity({EntityType? entityType, List<String?>? entityList}) {
|
||||
bool? shouldSelectEntity(
|
||||
{EntityType? entityType, List<String?>? entityList}) {
|
||||
final entityUIState = getUIState(entityType);
|
||||
|
||||
if (prefState.isMobile ||
|
||||
|
|
@ -962,11 +966,11 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
: 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
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ Middleware<AppState> _createCompany(AuthRepository repository) {
|
|||
store.dispatch(RefreshData(
|
||||
allCompanies: true,
|
||||
completer: Completer<Null>()
|
||||
..future.then<Null>((_) {
|
||||
..future.then<Null>(() {
|
||||
store.dispatch(SelectCompany(companyIndex: state.companies.length));
|
||||
store.dispatch(ViewDashboard(force: true));
|
||||
|
||||
|
|
@ -459,9 +459,9 @@ Middleware<AppState> _purgeData(AuthRepository repository) {
|
|||
store.dispatch(RefreshData(
|
||||
clearData: true,
|
||||
completer: Completer<Null>()
|
||||
..future.then((value) {
|
||||
..future.then<Null>(() {
|
||||
action.completer.complete(null);
|
||||
} as FutureOr<_> Function(Null))));
|
||||
} as FutureOr<Null> Function(Null))));
|
||||
}).catchError((Object error) {
|
||||
store.dispatch(PurgeDataFailure(error));
|
||||
action.completer.completeError(error);
|
||||
|
|
|
|||
|
|
@ -309,9 +309,9 @@ void handleCompanyGatewayAction(BuildContext? context,
|
|||
case EntityAction.disconnect:
|
||||
final completer =
|
||||
snackBarCompleter<Null>(context, localization!.disconnectedGateway);
|
||||
completer.future.then((value) {
|
||||
completer.future.then<Null>(() {
|
||||
store.dispatch(RefreshData());
|
||||
} as FutureOr<_> Function(Null));
|
||||
} as FutureOr<Null> Function(Null));
|
||||
confirmCallback(
|
||||
context: context,
|
||||
callback: (_) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -150,17 +150,18 @@ List<ChartDataGroup> _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<ChartDataGroup> 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<ChartDataGroup> 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<ChartDataGroup> chartExpenses(
|
|||
return data;
|
||||
}
|
||||
|
||||
var memoizedChartExpenses = memo5((BuiltMap<String?, CurrencyEntity?> currencyMap,
|
||||
CompanyEntity? company,
|
||||
DashboardUISettings settings,
|
||||
BuiltMap<String?, InvoiceEntity?> invoiceMap,
|
||||
BuiltMap<String?, ExpenseEntity?> expenseMap) =>
|
||||
chartExpenses(currencyMap, company!, settings, invoiceMap, expenseMap));
|
||||
var memoizedChartExpenses = memo5(
|
||||
(BuiltMap<String?, CurrencyEntity?> currencyMap,
|
||||
CompanyEntity? company,
|
||||
DashboardUISettings settings,
|
||||
BuiltMap<String?, InvoiceEntity?> invoiceMap,
|
||||
BuiltMap<String?, ExpenseEntity?> expenseMap) =>
|
||||
chartExpenses(currencyMap, company!, settings, invoiceMap, expenseMap));
|
||||
|
||||
var memoizedPreviousChartExpenses = memo5(
|
||||
(BuiltMap<String?, CurrencyEntity?> currencyMap,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue