From df7e3576b1e28e5d4c495c023558baaa8d1b1bcd Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 1 Oct 2023 14:51:35 +0300 Subject: [PATCH] Null safety --- lib/ui/client/view/client_view_details.dart | 10 +++++----- lib/ui/client/view/client_view_overview.dart | 4 ++-- lib/ui/company_gateway/edit/company_gateway_edit.dart | 5 ++--- lib/ui/reports/credit_report.dart | 8 ++++---- lib/ui/reports/invoice_report.dart | 6 +++--- lib/ui/reports/purchase_order_item_report.dart | 4 ++-- lib/ui/reports/purchase_order_report.dart | 6 +++--- lib/ui/reports/quote_report.dart | 6 +++--- lib/ui/reports/recurring_invoice_report.dart | 6 +++--- lib/ui/reports/reports_screen.dart | 11 +++++++---- 10 files changed, 34 insertions(+), 32 deletions(-) diff --git a/lib/ui/client/view/client_view_details.dart b/lib/ui/client/view/client_view_details.dart index 4b03e8574..7956c6613 100644 --- a/lib/ui/client/view/client_view_details.dart +++ b/lib/ui/client/view/client_view_details.dart @@ -101,7 +101,7 @@ class _ClientViewDetailsState extends State { }), )); - if ((contact.phone ?? '').isNotEmpty) { + if (contact.phone.isNotEmpty) { listTiles.add(AppListTile( icon: Icons.phone, title: (contact.fullName.isEmpty @@ -134,7 +134,7 @@ class _ClientViewDetailsState extends State { } }); - if ((client.website ?? '').isNotEmpty) { + if (client.website.isNotEmpty) { listTiles.add(AppListTile( icon: Icons.link, title: client.website, @@ -145,7 +145,7 @@ class _ClientViewDetailsState extends State { )); } - if ((client.phone ?? '').isNotEmpty) { + if (client.phone.isNotEmpty) { listTiles.add(AppListTile( icon: Icons.phone, title: client.phone, @@ -183,7 +183,7 @@ class _ClientViewDetailsState extends State { } */ - if ((client.vatNumber ?? '').isNotEmpty) { + if (client.vatNumber.isNotEmpty) { listTiles.add(AppListTile( icon: Icons.location_city, title: client.vatNumber, @@ -191,7 +191,7 @@ class _ClientViewDetailsState extends State { )); } - if ((client.idNumber ?? '').isNotEmpty) { + if (client.idNumber.isNotEmpty) { listTiles.add(AppListTile( icon: Icons.business, title: client.idNumber, diff --git a/lib/ui/client/view/client_view_overview.dart b/lib/ui/client/view/client_view_overview.dart index 1ae345936..2865da885 100644 --- a/lib/ui/client/view/client_view_overview.dart +++ b/lib/ui/client/view/client_view_overview.dart @@ -165,7 +165,7 @@ class ClientOverview extends StatelessWidget { ), ), ListDivider(), - if ((client.privateNotes ?? '').isNotEmpty) ...[ + if ((client.privateNotes).isNotEmpty) ...[ IconMessage(client.privateNotes, iconData: Icons.lock), ListDivider() ], @@ -301,7 +301,7 @@ class ClientOverview extends StatelessWidget { client.id, state.recurringExpenseState.map) .present(localization.active, localization.archived), ), - if ((client.publicNotes ?? '').isNotEmpty) ...[ + if (client.publicNotes.isNotEmpty) ...[ IconMessage(client.publicNotes, copyToClipboard: true), ListDivider() ], diff --git a/lib/ui/company_gateway/edit/company_gateway_edit.dart b/lib/ui/company_gateway/edit/company_gateway_edit.dart index cc1b504ac..b14c3ce49 100644 --- a/lib/ui/company_gateway/edit/company_gateway_edit.dart +++ b/lib/ui/company_gateway/edit/company_gateway_edit.dart @@ -159,9 +159,8 @@ class _CompanyGatewayEditState extends State viewModel.onChanged( companyGateway.rebuild((b) => b ..feesAndLimitsMap[((gateway ?? GatewayEntity()) - as GatewayEntity) - .defaultGatewayTypeId ?? - kGatewayTypeCreditCard] = + as GatewayEntity) + .defaultGatewayTypeId] = FeesAndLimitsSettings(isEnabled: true) ..gatewayId = gateway?.id ?? '' ..config = '{}' diff --git a/lib/ui/reports/credit_report.dart b/lib/ui/reports/credit_report.dart index 7505c2f20..743bbaceb 100644 --- a/lib/ui/reports/credit_report.dart +++ b/lib/ui/reports/credit_report.dart @@ -167,7 +167,7 @@ ReportResult creditReport( value = round(credit.balance * 1 / credit.exchangeRate, 2); break; case CreditReportFields.client: - value = client.listDisplayName ?? ''; + value = client.listDisplayName; break; case CreditReportFields.client_balance: value = client.balance; @@ -325,13 +325,13 @@ ReportResult creditReport( value = client.phone; break; case CreditReportFields.contact_email: - value = contact.email ?? ''; + value = contact.email; break; case CreditReportFields.contact_name: - value = contact.fullName ?? ''; + value = contact.fullName; break; case CreditReportFields.contact_phone: - value = contact.phone ?? ''; + value = contact.phone; break; case CreditReportFields.client_website: value = client.website; diff --git a/lib/ui/reports/invoice_report.dart b/lib/ui/reports/invoice_report.dart index bb2d4084e..01310665a 100644 --- a/lib/ui/reports/invoice_report.dart +++ b/lib/ui/reports/invoice_report.dart @@ -415,13 +415,13 @@ ReportResult invoiceReport( value = client.phone; break; case InvoiceReportFields.contact_email: - value = contact.email ?? ''; + value = contact.email; break; case InvoiceReportFields.contact_name: - value = contact.fullName ?? ''; + value = contact.fullName; break; case InvoiceReportFields.contact_phone: - value = contact.phone ?? ''; + value = contact.phone; break; case InvoiceReportFields.client_website: value = client.website; diff --git a/lib/ui/reports/purchase_order_item_report.dart b/lib/ui/reports/purchase_order_item_report.dart index 0884a7fe8..0e462af5b 100644 --- a/lib/ui/reports/purchase_order_item_report.dart +++ b/lib/ui/reports/purchase_order_item_report.dart @@ -198,10 +198,10 @@ ReportResult lineItemReport( ''; break; case PurchaseOrderItemReportFields.clientNumber: - value = client.number ?? ''; + value = client.number; break; case PurchaseOrderItemReportFields.clientIdNumber: - value = client.idNumber ?? ''; + value = client.idNumber; break; } diff --git a/lib/ui/reports/purchase_order_report.dart b/lib/ui/reports/purchase_order_report.dart index a369e77fd..32250620c 100644 --- a/lib/ui/reports/purchase_order_report.dart +++ b/lib/ui/reports/purchase_order_report.dart @@ -320,13 +320,13 @@ ReportResult purchaseOrderReport( value = vendor.phone; break; case PurchaseOrderReportFields.contact_email: - value = contact.email ?? ''; + value = contact.email; break; case PurchaseOrderReportFields.contact_name: - value = contact.fullName ?? ''; + value = contact.fullName; break; case PurchaseOrderReportFields.contact_phone: - value = contact.phone ?? ''; + value = contact.phone; break; case PurchaseOrderReportFields.vendor_website: value = vendor.website; diff --git a/lib/ui/reports/quote_report.dart b/lib/ui/reports/quote_report.dart index fbddca588..96f5780ce 100644 --- a/lib/ui/reports/quote_report.dart +++ b/lib/ui/reports/quote_report.dart @@ -319,13 +319,13 @@ ReportResult quoteReport( value = client.phone; break; case QuoteReportFields.contact_email: - value = contact.email ?? ''; + value = contact.email; break; case QuoteReportFields.contact_name: - value = contact.fullName ?? ''; + value = contact.fullName; break; case QuoteReportFields.contact_phone: - value = contact.phone ?? ''; + value = contact.phone; break; case QuoteReportFields.client_website: value = client.website; diff --git a/lib/ui/reports/recurring_invoice_report.dart b/lib/ui/reports/recurring_invoice_report.dart index a99d9c444..ea74ddc0f 100644 --- a/lib/ui/reports/recurring_invoice_report.dart +++ b/lib/ui/reports/recurring_invoice_report.dart @@ -338,13 +338,13 @@ ReportResult recurringInvoiceReport( value = client.phone; break; case RecurringInvoiceReportFields.contact_email: - value = contact.email ?? ''; + value = contact.email; break; case RecurringInvoiceReportFields.contact_name: - value = contact.fullName ?? ''; + value = contact.fullName; break; case RecurringInvoiceReportFields.contact_phone: - value = contact.phone ?? ''; + value = contact.phone; break; case RecurringInvoiceReportFields.client_website: value = client.website; diff --git a/lib/ui/reports/reports_screen.dart b/lib/ui/reports/reports_screen.dart index b9981bb8a..f57da8681 100644 --- a/lib/ui/reports/reports_screen.dart +++ b/lib/ui/reports/reports_screen.dart @@ -364,7 +364,7 @@ class ReportsScreen extends StatelessWidget { viewModel.onReportColumnsChanged( context, selected); }, - options: reportResult.allColumns ?? [], + options: reportResult.allColumns, selected: reportResult.columns.toList(), defaultSelected: reportResult.defaultColumns, ); @@ -691,7 +691,7 @@ class _ReportDataTableState extends State { sortColumnIndex: sortedColumns.contains(reportSettings.sortColumn) ? sortedColumns.indexOf(reportSettings.sortColumn) : null, - sortAscending: reportSettings.sortAscending ?? true, + sortAscending: reportSettings.sortAscending, columns: reportResult.tableColumns( context, (index, ascending) => widget.viewModel @@ -705,8 +705,11 @@ class _ReportDataTableState extends State { } class TotalsDataTable extends StatelessWidget { - const TotalsDataTable( - {this.reportSettings, this.reportResult, this.viewModel}); + const TotalsDataTable({ + this.reportSettings, + this.reportResult, + this.viewModel, + }); final ReportsScreenVM? viewModel; final ReportSettingsEntity? reportSettings;