Null safety

This commit is contained in:
Hillel Coren 2023-09-19 17:13:13 +03:00
parent e5b0ba8365
commit 818e39a0e8
14 changed files with 31 additions and 28 deletions

View File

@ -17,7 +17,7 @@ class DesignPicker extends StatelessWidget {
this.initialValue, this.initialValue,
}); });
final Function(DesignEntity?) onSelected; final Function(DesignEntity) onSelected;
final String? label; final String? label;
final String? initialValue; final String? initialValue;

View File

@ -101,7 +101,7 @@ class CreditEditDetailsVM extends EntityEditDetailsVM {
force: true, force: true,
completer: completer, completer: completer,
cancelCompleter: Completer<Null>() cancelCompleter: Completer<Null>()
..future.then((_) { ..future.then<Null>(() {
store.dispatch(UpdateCurrentRoute(CreditEditScreen.route)); store.dispatch(UpdateCurrentRoute(CreditEditScreen.route));
} as FutureOr<Null> Function(Null))); } as FutureOr<Null> Function(Null)));
completer.future.then((SelectableEntity client) { completer.future.then((SelectableEntity client) {

View File

@ -414,7 +414,7 @@ class DashboardPanels extends StatelessWidget {
final previousExpenseData = memoizedPreviousChartExpenses( final previousExpenseData = memoizedPreviousChartExpenses(
state.staticState.currencyMap, state.staticState.currencyMap,
state.company, state.company,
settings.rebuild((b) => b..offset += 1), settings.rebuild((b) => b..offset = settings.offset + 1),
state.invoiceState.map, state.invoiceState.map,
state.expenseState.map); state.expenseState.map);
@ -481,8 +481,8 @@ class DashboardPanels extends StatelessWidget {
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
child: child: Text(
Text(localization!.addGatewayHelpMessage!), localization!.addGatewayHelpMessage!),
), ),
if (isDesktop(context)) if (isDesktop(context))
TextButton( TextButton(
@ -633,7 +633,8 @@ class DashboardPanels extends StatelessWidget {
return FormCard( return FormCard(
padding: const EdgeInsets.all(0), padding: const EdgeInsets.all(0),
children: [ children: [
Text(localization!.lookup(dashboardField.field)!, Text(
localization!.lookup(dashboardField.field)!,
style: textTheme.titleMedium, style: textTheme.titleMedium,
textAlign: TextAlign.center), textAlign: TextAlign.center),
SizedBox(height: 6), SizedBox(height: 6),
@ -647,7 +648,8 @@ class DashboardPanels extends StatelessWidget {
style: textTheme.headlineSmall, style: textTheme.headlineSmall,
textAlign: TextAlign.center), textAlign: TextAlign.center),
SizedBox(height: 6), SizedBox(height: 6),
Text(localization.lookup(dashboardField.period)!, Text(
localization.lookup(dashboardField.period)!,
style: textTheme.bodySmall, style: textTheme.bodySmall,
textAlign: TextAlign.center), textAlign: TextAlign.center),
], ],

View File

@ -230,7 +230,8 @@ class _DesignEditState extends State<DesignEdit>
return EditScaffold( return EditScaffold(
entity: design, entity: design,
isFullscreen: true, isFullscreen: true,
title: design.isNew ? localization!.newDesign : localization!.editDesign, title:
design.isNew ? localization!.newDesign : localization!.editDesign,
onCancelPressed: (context) => viewModel.onCancelPressed(context), onCancelPressed: (context) => viewModel.onCancelPressed(context),
appBarBottom: isMobile(context) appBarBottom: isMobile(context)
? TabBar( ? TabBar(

View File

@ -57,7 +57,7 @@ class DocumentPresenter extends EntityPresenter {
case DocumentFields.id: case DocumentFields.id:
return Text(document!.id); return Text(document!.id);
case DocumentFields.hash: case DocumentFields.hash:
return Text(document.hash); return Text(document!.hash);
case DocumentFields.linkedTo: case DocumentFields.linkedTo:
final parentEntity = final parentEntity =
state.getEntity(document!.parentType, document.parentId); state.getEntity(document!.parentType, document.parentId);

View File

@ -129,7 +129,7 @@ class InvoiceEditDetailsVM extends EntityEditDetailsVM {
force: true, force: true,
completer: completer, completer: completer,
cancelCompleter: Completer<Null>() cancelCompleter: Completer<Null>()
..future.then((_) { ..future.then<Null>(() {
store.dispatch(UpdateCurrentRoute(InvoiceEditScreen.route)); store.dispatch(UpdateCurrentRoute(InvoiceEditScreen.route));
} as FutureOr<Null> Function(Null))); } as FutureOr<Null> Function(Null)));
completer.future.then((SelectableEntity client) { completer.future.then((SelectableEntity client) {

View File

@ -208,7 +208,8 @@ class InvoiceEditVM extends AbstractInvoiceEditVM {
..projectId = projectId ?? '' ..projectId = projectId ?? ''
..invitations.replace(BuiltList<InvitationEntity>(client! ..invitations.replace(BuiltList<InvitationEntity>(client!
.emailContacts .emailContacts
.map((contact) => InvitationEntity(clientContactId: contact!.id)) .map(
(contact) => InvitationEntity(clientContactId: contact!.id))
.toList()))))); .toList())))));
} }
store.dispatch(AddInvoiceItems(items)); store.dispatch(AddInvoiceItems(items));

View File

@ -88,7 +88,7 @@ class ProjectEditVM {
force: true, force: true,
completer: completer, completer: completer,
cancelCompleter: Completer<Null>() cancelCompleter: Completer<Null>()
..future.then((_) { ..future.then<Null>(() {
store.dispatch(UpdateCurrentRoute(ProjectEditScreen.route)); store.dispatch(UpdateCurrentRoute(ProjectEditScreen.route));
} as FutureOr<Null> Function(Null))); } as FutureOr<Null> Function(Null)));
completer.future.then((SelectableEntity client) { completer.future.then((SelectableEntity client) {

View File

@ -48,7 +48,7 @@ class RecurringExpenseEditVM extends AbstractExpenseEditVM {
AppState? state, AppState? state,
ExpenseEntity? expense, ExpenseEntity? expense,
Function(ExpenseEntity)? onChanged, Function(ExpenseEntity)? onChanged,
Function(BuildContext)? onSavePressed, Function(BuildContext, [EntityAction?])? onSavePressed,
Function(BuildContext)? onCancelPressed, Function(BuildContext)? onCancelPressed,
bool? isLoading, bool? isLoading,
bool? isSaving, bool? isSaving,
@ -62,8 +62,7 @@ class RecurringExpenseEditVM extends AbstractExpenseEditVM {
state: state, state: state,
expense: expense, expense: expense,
onChanged: onChanged, onChanged: onChanged,
onSavePressed: onSavePressed: onSavePressed,
onSavePressed as dynamic Function(BuildContext, [EntityAction])?,
onCancelPressed: onCancelPressed, onCancelPressed: onCancelPressed,
origExpense: origExpense, origExpense: origExpense,
onAddClientPressed: onAddClientPressed, onAddClientPressed: onAddClientPressed,
@ -91,10 +90,10 @@ class RecurringExpenseEditVM extends AbstractExpenseEditVM {
force: true, force: true,
completer: completer, completer: completer,
cancelCompleter: Completer<Null>() cancelCompleter: Completer<Null>()
..future.then((_) { ..future.then<Null>(() {
store.dispatch( store.dispatch(
UpdateCurrentRoute(RecurringExpenseEditScreen.route)); UpdateCurrentRoute(RecurringExpenseEditScreen.route));
} as FutureOr<Null> Function(Null))); } as FutureOr<_> Function(Null)));
completer.future.then((SelectableEntity client) { completer.future.then((SelectableEntity client) {
store.dispatch(UpdateCurrentRoute(RecurringExpenseEditScreen.route)); store.dispatch(UpdateCurrentRoute(RecurringExpenseEditScreen.route));
}); });
@ -106,7 +105,7 @@ class RecurringExpenseEditVM extends AbstractExpenseEditVM {
force: true, force: true,
completer: completer, completer: completer,
cancelCompleter: Completer<Null>() cancelCompleter: Completer<Null>()
..future.then((_) { ..future.then<Null>(() {
store.dispatch( store.dispatch(
UpdateCurrentRoute(RecurringExpenseEditScreen.route)); UpdateCurrentRoute(RecurringExpenseEditScreen.route));
} as FutureOr<Null> Function(Null))); } as FutureOr<Null> Function(Null)));

View File

@ -57,8 +57,8 @@ class RecurringInvoiceEditDetailsVM extends EntityEditDetailsVM {
CompanyEntity? company, CompanyEntity? company,
InvoiceEntity? invoice, InvoiceEntity? invoice,
Function(InvoiceEntity)? onChanged, Function(InvoiceEntity)? onChanged,
Function(BuildContext, InvoiceEntity, ClientEntity)? onClientChanged, Function(BuildContext, InvoiceEntity, ClientEntity?)? onClientChanged,
Function(BuildContext, InvoiceEntity, VendorEntity)? onVendorChanged, Function(BuildContext, InvoiceEntity, VendorEntity?)? onVendorChanged,
BuiltMap<String?, ClientEntity?>? clientMap, BuiltMap<String?, ClientEntity?>? clientMap,
BuiltList<String>? clientList, BuiltList<String>? clientList,
Function(BuildContext context, Completer<SelectableEntity> completer)? Function(BuildContext context, Completer<SelectableEntity> completer)?
@ -103,7 +103,7 @@ class RecurringInvoiceEditDetailsVM extends EntityEditDetailsVM {
force: true, force: true,
completer: completer, completer: completer,
cancelCompleter: Completer<Null>() cancelCompleter: Completer<Null>()
..future.then((_) { ..future.then<Null>(() {
store.dispatch( store.dispatch(
UpdateCurrentRoute(RecurringInvoiceEditScreen.route)); UpdateCurrentRoute(RecurringInvoiceEditScreen.route));
} as FutureOr<Null> Function(Null))); } as FutureOr<Null> Function(Null)));

View File

@ -52,7 +52,7 @@ class RecurringInvoiceEditVM extends AbstractInvoiceEditVM {
InvoiceEntity? invoice, InvoiceEntity? invoice,
int? invoiceItemIndex, int? invoiceItemIndex,
InvoiceEntity? origInvoice, InvoiceEntity? origInvoice,
Function(BuildContext)? onSavePressed, Function(BuildContext, [EntityAction?])? onSavePressed,
Function(List<InvoiceItemEntity>, String, String)? onItemsAdded, Function(List<InvoiceItemEntity>, String, String)? onItemsAdded,
bool? isSaving, bool? isSaving,
Function(BuildContext)? onCancelPressed, Function(BuildContext)? onCancelPressed,
@ -63,7 +63,7 @@ class RecurringInvoiceEditVM extends AbstractInvoiceEditVM {
invoice: invoice, invoice: invoice,
invoiceItemIndex: invoiceItemIndex, invoiceItemIndex: invoiceItemIndex,
origInvoice: origInvoice, origInvoice: origInvoice,
onSavePressed: onSavePressed as dynamic Function(BuildContext, [EntityAction])?, onSavePressed: onSavePressed,
onItemsAdded: onItemsAdded, onItemsAdded: onItemsAdded,
isSaving: isSaving, isSaving: isSaving,
onCancelPressed: onCancelPressed, onCancelPressed: onCancelPressed,

View File

@ -82,7 +82,7 @@ class TaskEditDetailsVM {
force: true, force: true,
completer: completer, completer: completer,
cancelCompleter: Completer<Null>() cancelCompleter: Completer<Null>()
..future.then((_) { ..future.then<Null>(() {
store.dispatch(UpdateCurrentRoute(TaskEditDetailsScreen.route)); store.dispatch(UpdateCurrentRoute(TaskEditDetailsScreen.route));
} as FutureOr<Null> Function(Null))); } as FutureOr<Null> Function(Null)));
completer.future.then((SelectableEntity client) { completer.future.then((SelectableEntity client) {
@ -107,7 +107,7 @@ class TaskEditDetailsVM {
force: true, force: true,
completer: completer, completer: completer,
cancelCompleter: Completer<Null>() cancelCompleter: Completer<Null>()
..future.then((_) { ..future.then<Null>(() {
store.dispatch(UpdateCurrentRoute(TaskEditDetailsScreen.route)); store.dispatch(UpdateCurrentRoute(TaskEditDetailsScreen.route));
} as FutureOr<Null> Function(Null))); } as FutureOr<Null> Function(Null)));
completer.future.then((SelectableEntity client) { completer.future.then((SelectableEntity client) {

View File

@ -110,7 +110,7 @@ class TransactionEditVM {
force: true, force: true,
completer: completer, completer: completer,
cancelCompleter: Completer<Null>() cancelCompleter: Completer<Null>()
..future.then((_) { ..future.then<Null>(() {
store.dispatch(UpdateCurrentRoute(TransactionEditScreen.route)); store.dispatch(UpdateCurrentRoute(TransactionEditScreen.route));
} as FutureOr<Null> Function(Null))); } as FutureOr<Null> Function(Null)));
completer.future.then((SelectableEntity client) { completer.future.then((SelectableEntity client) {

View File

@ -1109,7 +1109,7 @@ class _MatchWithdrawalsState extends State<_MatchWithdrawals> {
force: true, force: true,
completer: completer, completer: completer,
cancelCompleter: Completer<Null>() cancelCompleter: Completer<Null>()
..future.then((_) { ..future.then<Null>(() {
store.dispatch(UpdateCurrentRoute( store.dispatch(UpdateCurrentRoute(
TransactionScreen.route)); TransactionScreen.route));
} as FutureOr<Null> Function(Null))); } as FutureOr<Null> Function(Null)));
@ -1193,7 +1193,7 @@ class _MatchWithdrawalsState extends State<_MatchWithdrawals> {
force: true, force: true,
completer: completer, completer: completer,
cancelCompleter: Completer<Null>() cancelCompleter: Completer<Null>()
..future.then((_) { ..future.then<Null>(() {
store.dispatch(UpdateCurrentRoute( store.dispatch(UpdateCurrentRoute(
TransactionScreen.route)); TransactionScreen.route));
} as FutureOr<Null> Function(Null))); } as FutureOr<Null> Function(Null)));