Null safety
This commit is contained in:
parent
b328d56c23
commit
96fea81865
|
|
@ -599,7 +599,7 @@ class _AccountOverview extends StatelessWidget {
|
|||
context: context,
|
||||
callback: (password, idToken) {
|
||||
viewModel.onPurgeData(
|
||||
context, password, idToken);
|
||||
context, password ?? '', idToken ?? '');
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
@ -648,10 +648,10 @@ class _AccountOverview extends StatelessWidget {
|
|||
);
|
||||
|
||||
viewModel.onCompanyDelete(
|
||||
navigatorKey.currentContext,
|
||||
navigatorKey.currentContext!,
|
||||
'',
|
||||
credentials.identityToken,
|
||||
reason,
|
||||
credentials.identityToken ?? '',
|
||||
reason ?? '',
|
||||
);
|
||||
} else {
|
||||
passwordCallback(
|
||||
|
|
@ -660,9 +660,9 @@ class _AccountOverview extends StatelessWidget {
|
|||
callback: (password, idToken) {
|
||||
viewModel.onCompanyDelete(
|
||||
context,
|
||||
password,
|
||||
idToken,
|
||||
reason,
|
||||
password ?? '',
|
||||
idToken ?? '',
|
||||
reason ?? '',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class AccountManagementVM {
|
|||
store.dispatch(UpdateCompany(company: company)),
|
||||
onCompanyDelete: (context, password, idToken, reason) {
|
||||
showDialog<AlertDialog>(
|
||||
context: context,
|
||||
context: context!,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) => SimpleDialog(
|
||||
children: <Widget>[LoadingDialog()],
|
||||
|
|
@ -74,7 +74,7 @@ class AccountManagementVM {
|
|||
final companyLength = state.companies.length;
|
||||
final deleteCompleter = Completer<Null>()
|
||||
..future
|
||||
.then((value) {
|
||||
.then<Null>(() {
|
||||
final context = navigatorKey.currentContext;
|
||||
final state = store.state;
|
||||
if (companyLength == 1) {
|
||||
|
|
@ -87,7 +87,7 @@ class AccountManagementVM {
|
|||
final index = selectedCompanyIndex == 0 ? 1 : 0;
|
||||
store.dispatch(SelectCompany(companyIndex: index));
|
||||
final refreshCompleter = Completer<Null>()
|
||||
..future.then((value) {
|
||||
..future.then<Null>(() {
|
||||
store.dispatch(SelectCompany(companyIndex: 0));
|
||||
store.dispatch(ViewDashboard());
|
||||
AppBuilder.of(navigatorKey.currentContext!)!.rebuild();
|
||||
|
|
@ -99,7 +99,7 @@ class AccountManagementVM {
|
|||
store.dispatch(
|
||||
RefreshData(clearData: true, completer: refreshCompleter));
|
||||
}
|
||||
} as FutureOr<_> Function(Null))
|
||||
} as FutureOr<Null> Function(Null))
|
||||
.catchError((Object error) {
|
||||
if (Navigator.of(navigatorKey.currentContext!).canPop()) {
|
||||
Navigator.of(navigatorKey.currentContext!).pop();
|
||||
|
|
@ -151,7 +151,7 @@ class AccountManagementVM {
|
|||
final CompanyEntity company;
|
||||
final Function(BuildContext) onSetPrimaryCompany;
|
||||
final Function(CompanyEntity) onCompanyChanged;
|
||||
final Function(BuildContext?, String?, String?, String?) onCompanyDelete;
|
||||
final Function(BuildContext, String?, String?) onPurgeData;
|
||||
final Function(BuildContext, String, String, String) onCompanyDelete;
|
||||
final Function(BuildContext, String, String) onPurgeData;
|
||||
final Function onAppliedLicense;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
// Flutter imports:
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
|
|
@ -80,7 +82,7 @@ class ClientPortalVM {
|
|||
final oldSubdomain = state.company!.subdomain;
|
||||
final newSubdomain = settingsUIState.company.subdomain;
|
||||
if (oldSubdomain != newSubdomain) {
|
||||
completer.future.then((value) {
|
||||
completer.future.then<Null>(() {
|
||||
showRefreshDataDialog(
|
||||
context: navigatorKey.currentContext!);
|
||||
} as FutureOr<Null> Function(Null));
|
||||
|
|
|
|||
|
|
@ -560,7 +560,7 @@ class _CompanyDetailsState extends State<CompanyDetails>
|
|||
if (multipartFiles != null &&
|
||||
multipartFiles.isNotEmpty) {
|
||||
viewModel.onUploadLogo(
|
||||
navigatorKey.currentContext,
|
||||
navigatorKey.currentContext!,
|
||||
multipartFiles.first);
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ class CompanyDetailsVM {
|
|||
final Function(SettingsEntity) onSettingsChanged;
|
||||
final Function(CompanyEntity) onCompanyChanged;
|
||||
final Function(BuildContext) onSavePressed;
|
||||
final Function(BuildContext?, MultipartFile) onUploadLogo;
|
||||
final Function(BuildContext, MultipartFile) onUploadLogo;
|
||||
final Function(BuildContext) onDeleteLogo;
|
||||
final Function(BuildContext) onConfigurePaymentTermsPressed;
|
||||
final Function(BuildContext, List<MultipartFile>, bool) onUploadDocuments;
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ class _DeviceSettingsState extends State<DeviceSettings>
|
|||
value: prefState.appLayout == AppLayout.mobile,
|
||||
onChanged: (value) {
|
||||
viewModel.onLayoutChanged(context,
|
||||
value ? AppLayout.mobile : AppLayout.desktop);
|
||||
value == true ? AppLayout.mobile : AppLayout.desktop);
|
||||
},
|
||||
enabledLabel: localization.mobile,
|
||||
disabledLabel: localization.desktop,
|
||||
|
|
@ -132,7 +132,7 @@ class _DeviceSettingsState extends State<DeviceSettings>
|
|||
onChanged: (value) {
|
||||
viewModel.onMenuModeChanged(
|
||||
context,
|
||||
value
|
||||
value == true
|
||||
? AppSidebarMode.float
|
||||
: AppSidebarMode.collapse,
|
||||
);
|
||||
|
|
@ -147,7 +147,9 @@ class _DeviceSettingsState extends State<DeviceSettings>
|
|||
onChanged: (value) {
|
||||
viewModel.onHistoryModeChanged(
|
||||
context,
|
||||
value ? AppSidebarMode.float : AppSidebarMode.visible,
|
||||
value == true
|
||||
? AppSidebarMode.float
|
||||
: AppSidebarMode.visible,
|
||||
);
|
||||
},
|
||||
enabledLabel: localization.float,
|
||||
|
|
@ -159,7 +161,7 @@ class _DeviceSettingsState extends State<DeviceSettings>
|
|||
label: localization.clickSelected,
|
||||
value: prefState.tapSelectedToEdit,
|
||||
onChanged: (value) {
|
||||
viewModel.onTapSelectedChanged(context, value);
|
||||
viewModel.onTapSelectedChanged(context, value == true);
|
||||
},
|
||||
enabledLabel: localization.editRecord,
|
||||
disabledLabel: localization.hidePreview,
|
||||
|
|
@ -168,7 +170,8 @@ class _DeviceSettingsState extends State<DeviceSettings>
|
|||
label: localization.afterSaving,
|
||||
value: prefState.editAfterSaving,
|
||||
onChanged: (value) {
|
||||
viewModel.onEditAfterSavingChanged(context, value);
|
||||
viewModel.onEditAfterSavingChanged(
|
||||
context, value == true);
|
||||
},
|
||||
enabledLabel: localization.editRecord,
|
||||
disabledLabel: localization.viewRecord,
|
||||
|
|
@ -179,7 +182,7 @@ class _DeviceSettingsState extends State<DeviceSettings>
|
|||
value: !prefState.longPressSelectionIsDefault,
|
||||
onChanged: (value) {
|
||||
viewModel.onLongPressSelectionIsDefault(
|
||||
context, !value);
|
||||
context, value == false);
|
||||
},
|
||||
enabledLabel: localization.showActions,
|
||||
disabledLabel: localization.startMultiselect,
|
||||
|
|
@ -213,7 +216,8 @@ class _DeviceSettingsState extends State<DeviceSettings>
|
|||
label: localization.previewLocation,
|
||||
value: prefState.showPdfPreviewSideBySide,
|
||||
onChanged: (value) {
|
||||
viewModel.onShowPdfSideBySideChanged(context, value);
|
||||
viewModel.onShowPdfSideBySideChanged(
|
||||
context, value == true);
|
||||
},
|
||||
disabledLabel: localization.bottom,
|
||||
enabledLabel: localization.side,
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ class _ImportExportState extends State<ImportExport> {
|
|||
}
|
||||
},
|
||||
onImportTypeChanged: (importType) =>
|
||||
setState(() => _importFormat = importType),
|
||||
setState(() => _importFormat = importType!),
|
||||
)
|
||||
else
|
||||
_FileMapper(
|
||||
|
|
|
|||
|
|
@ -575,8 +575,8 @@ class _InvoiceDesignState extends State<InvoiceDesign>
|
|||
value: !(settings.hideEmptyColumnsOnPdf ?? false),
|
||||
iconData: MdiIcons.table,
|
||||
onChanged: (value) => viewModel.onSettingsChanged(
|
||||
settings.rebuild(
|
||||
(b) => b..hideEmptyColumnsOnPdf = !value),
|
||||
settings.rebuild((b) =>
|
||||
b..hideEmptyColumnsOnPdf = value == false),
|
||||
),
|
||||
enabledLabel: localization.show,
|
||||
disabledLabel: localization.hide,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// Dart imports:
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
// Flutter imports:
|
||||
|
|
@ -82,7 +83,7 @@ class InvoiceDesignVM {
|
|||
case EntityType.company:
|
||||
final completer = snackBarCompleter<Null>(
|
||||
context, AppLocalization.of(context)!.savedSettings)
|
||||
..future.then((value) {
|
||||
..future.then<Null>(() {
|
||||
final webClient = WebClient();
|
||||
final credentials = state.credentials;
|
||||
final url = '${credentials.url}/designs/set/default';
|
||||
|
|
|
|||
|
|
@ -419,7 +419,7 @@ class _AddCompanyDialogState extends State<_AddCompanyDialog> {
|
|||
entityList: memoizedCountryList(state.staticState.countryMap),
|
||||
labelText: localization.country,
|
||||
onSelected: (SelectableEntity? country) {
|
||||
_countryId = country.id;
|
||||
_countryId = country?.id ?? '';
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -147,16 +147,16 @@ class _SettingsWizardState extends State<SettingsWizard> {
|
|||
final localization = AppLocalization.of(context);
|
||||
final completer = Completer<Null>();
|
||||
completer.future
|
||||
.then((value) {
|
||||
.then<Null>(() {
|
||||
final toastCompleter =
|
||||
snackBarCompleter<Null>(context, localization!.savedSettings);
|
||||
toastCompleter.future
|
||||
.then((value) {
|
||||
.then<Null>(() {
|
||||
setState(() {
|
||||
_isSaving = false;
|
||||
_showLogo = true;
|
||||
});
|
||||
} as FutureOr<_> Function(Null))
|
||||
} as FutureOr<Null> Function(Null))
|
||||
.catchError((Object error) {
|
||||
setState(() {
|
||||
_isSaving = false;
|
||||
|
|
@ -174,7 +174,7 @@ class _SettingsWizardState extends State<SettingsWizard> {
|
|||
),
|
||||
),
|
||||
);
|
||||
} as FutureOr<_> Function(Null))
|
||||
} as FutureOr<Null> Function(Null))
|
||||
.catchError((Object error) {
|
||||
setState(() => _isSaving = false);
|
||||
});
|
||||
|
|
@ -237,7 +237,7 @@ class _SettingsWizardState extends State<SettingsWizard> {
|
|||
labelText: localization.currency,
|
||||
entityId: _currencyId,
|
||||
onSelected: (SelectableEntity? currency) =>
|
||||
setState(() => _currencyId = currency?.id),
|
||||
setState(() => _currencyId = currency?.id ?? ''),
|
||||
validator: (dynamic value) =>
|
||||
value.isEmpty ? localization.pleaseEnterAValue : null,
|
||||
);
|
||||
|
|
@ -248,7 +248,7 @@ class _SettingsWizardState extends State<SettingsWizard> {
|
|||
labelText: localization.language,
|
||||
entityId: _languageId,
|
||||
onSelected: (SelectableEntity? language) {
|
||||
setState(() => _languageId = language?.id);
|
||||
setState(() => _languageId = language?.id ?? '');
|
||||
store.dispatch(UpdateCompanyLanguage(languageId: language?.id));
|
||||
AppBuilder.of(context)!.rebuild();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ class TemplatesAndRemindersVM {
|
|||
case EntityType.company:
|
||||
final completer = snackBarCompleter<Null>(
|
||||
context, AppLocalization.of(context)!.savedSettings);
|
||||
completer.future.then(
|
||||
((value) => callback()) as FutureOr<Null> Function(Null));
|
||||
completer.future.then<Null>(
|
||||
(() => callback()) as FutureOr<Null> Function(Null));
|
||||
store.dispatch(SaveCompanyRequest(
|
||||
completer: completer, company: settingsUIState.company));
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ class UserDetailsVM {
|
|||
final appBuilder = AppBuilder.of(context);
|
||||
final origUserSettings = state.userCompany!.settings;
|
||||
|
||||
completer.future.then((_) async {
|
||||
completer.future.then<Null>(() async {
|
||||
final newUserSettings = store.state.userCompany!.settings!;
|
||||
if (origUserSettings!.includeDeletedClients !=
|
||||
newUserSettings.includeDeletedClients ||
|
||||
|
|
|
|||
|
|
@ -252,15 +252,18 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
|
|||
entityMap: state.productState.map,
|
||||
labelText: localization.oneTimeProducts,
|
||||
onSelected: (value) {
|
||||
if (value != null) {
|
||||
final parts = subscription.productIds.split(',');
|
||||
viewModel.onChanged(subscription.rebuild((b) => b
|
||||
..productIds = <String>[...parts, value.id]
|
||||
.where((part) => part.isNotEmpty)
|
||||
.join(',')));
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((duration) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((duration) {
|
||||
FocusScope.of(context).unfocus();
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
|
|
@ -338,15 +341,19 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
|
|||
entityMap: state.productState.map,
|
||||
labelText: localization.optionalOneTimeProducts,
|
||||
onSelected: (value) {
|
||||
final parts = subscription.optionalProductIds.split(',');
|
||||
if (value != null) {
|
||||
final parts =
|
||||
subscription.optionalProductIds.split(',');
|
||||
viewModel.onChanged(subscription.rebuild((b) => b
|
||||
..optionalProductIds = <String>[...parts, value.id]
|
||||
.where((part) => part.isNotEmpty)
|
||||
.join(',')));
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((duration) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((duration) {
|
||||
FocusScope.of(context).unfocus();
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
|
|
@ -380,6 +387,7 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
|
|||
entityMap: state.productState.map,
|
||||
labelText: localization.optionalRecurringProducts,
|
||||
onSelected: (value) {
|
||||
if (value != null) {
|
||||
final parts =
|
||||
subscription.optionalRecurringProductIds.split(',');
|
||||
viewModel.onChanged(subscription.rebuild((b) => b
|
||||
|
|
@ -388,9 +396,11 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
|
|||
value.id
|
||||
].where((part) => part.isNotEmpty).join(',')));
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((duration) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((duration) {
|
||||
FocusScope.of(context).unfocus();
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
|
|
|
|||
|
|
@ -332,11 +332,13 @@ class _TaskEditDesktopState extends State<TaskEditDesktop> {
|
|||
labelText: settings.showTaskItemDescription!
|
||||
? localization.startDate
|
||||
: null,
|
||||
selectedDate: taskTimes[index]!.startDate ==
|
||||
null
|
||||
selectedDate:
|
||||
taskTimes[index]!.startDate == null
|
||||
? null
|
||||
: convertDateTimeToSqlDate(
|
||||
taskTimes[index]!.startDate!.toLocal()),
|
||||
taskTimes[index]!
|
||||
.startDate!
|
||||
.toLocal()),
|
||||
onSelected: (date, _) {
|
||||
final taskTime = taskTimes[index]!
|
||||
.copyWithStartDate(date,
|
||||
|
|
@ -363,6 +365,10 @@ class _TaskEditDesktopState extends State<TaskEditDesktop> {
|
|||
: null,
|
||||
selectedDateTime: taskTimes[index]!.startDate,
|
||||
onSelected: (timeOfDay) {
|
||||
if (timeOfDay == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final taskTime = taskTimes[index]!
|
||||
.copyWithStartTime(timeOfDay);
|
||||
viewModel.onUpdatedTaskTime(
|
||||
|
|
@ -386,11 +392,13 @@ class _TaskEditDesktopState extends State<TaskEditDesktop> {
|
|||
labelText: settings.showTaskItemDescription!
|
||||
? localization.endDate
|
||||
: null,
|
||||
selectedDate: taskTimes[index]!.endDate ==
|
||||
null
|
||||
selectedDate:
|
||||
taskTimes[index]!.endDate == null
|
||||
? null
|
||||
: convertDateTimeToSqlDate(
|
||||
taskTimes[index]!.endDate!.toLocal()),
|
||||
taskTimes[index]!
|
||||
.endDate!
|
||||
.toLocal()),
|
||||
onSelected: (date, _) {
|
||||
final taskTime = taskTimes[index]!
|
||||
.copyWithEndDate(date);
|
||||
|
|
@ -417,6 +425,10 @@ class _TaskEditDesktopState extends State<TaskEditDesktop> {
|
|||
selectedDateTime: taskTimes[index]!.endDate,
|
||||
isEndTime: true,
|
||||
onSelected: (timeOfDay) {
|
||||
if (timeOfDay == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final taskTime = taskTimes[index]!
|
||||
.copyWithEndTime(timeOfDay);
|
||||
viewModel.onUpdatedTaskTime(
|
||||
|
|
|
|||
|
|
@ -145,8 +145,8 @@ class TimeEditDetailsState extends State<TimeEditDetails> {
|
|||
: convertDateTimeToSqlDate(_taskTime!.startDate!.toLocal()),
|
||||
onSelected: (date, _) {
|
||||
setState(() {
|
||||
_taskTime = _taskTime!.copyWithStartDate(date,
|
||||
syncDates: !showEndDate);
|
||||
_taskTime = _taskTime!
|
||||
.copyWithStartDate(date, syncDates: !showEndDate);
|
||||
viewModel.onUpdatedTaskTime(_taskTime, widget.index);
|
||||
_startDateUpdatedAt = DateTime.now().millisecondsSinceEpoch;
|
||||
});
|
||||
|
|
@ -157,6 +157,10 @@ class TimeEditDetailsState extends State<TimeEditDetails> {
|
|||
labelText: localization.startTime,
|
||||
selectedDateTime: _taskTime!.startDate,
|
||||
onSelected: (timeOfDay) {
|
||||
if (timeOfDay == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_taskTime = _taskTime!.copyWithStartTime(timeOfDay);
|
||||
viewModel.onUpdatedTaskTime(_taskTime, widget.index);
|
||||
|
|
@ -188,6 +192,10 @@ class TimeEditDetailsState extends State<TimeEditDetails> {
|
|||
isEndTime: true,
|
||||
onSelected: (timeOfDay) {
|
||||
setState(() {
|
||||
if (timeOfDay == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
_taskTime = _taskTime!.copyWithEndTime(timeOfDay);
|
||||
viewModel.onUpdatedTaskTime(_taskTime, widget.index);
|
||||
_endTimeUpdatedAt = DateTime.now().millisecondsSinceEpoch;
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ class TaskEditVM {
|
|||
final int? taskTimeIndex;
|
||||
final CompanyEntity? company;
|
||||
final Function(BuildContext, [EntityAction?]) onSavePressed;
|
||||
final Function(BuildContext?) onCancelPressed;
|
||||
final Function(BuildContext) onCancelPressed;
|
||||
final Function onFabPressed;
|
||||
final bool isLoading;
|
||||
final bool isSaving;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class _TaskOverviewState extends State<TaskOverview> {
|
|||
final company = viewModel.company!;
|
||||
final invoice = viewModel.state.invoiceState.map[task.invoiceId];
|
||||
final user = viewModel.state.userState.map[task.assignedUserId];
|
||||
final group = state.groupState.get(client?.groupId);
|
||||
final group = state.groupState.get(client?.groupId ?? '');
|
||||
final status = state.taskStatusState.get(task.statusId);
|
||||
|
||||
final Map<String, String?> fields = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue