Null safety

This commit is contained in:
Hillel Coren 2023-10-01 18:47:54 +03:00
parent 87699ac2b6
commit 5b321a4fb1
7 changed files with 18 additions and 18 deletions

View File

@ -138,6 +138,7 @@ abstract class AccountEntity
// ignore: unused_element // ignore: unused_element
static void _initializeBuilder(AccountEntityBuilder builder) => builder static void _initializeBuilder(AccountEntityBuilder builder) => builder
..key = '' ..key = ''
..currentVersion = ''
..debugEnabled = false ..debugEnabled = false
..isDocker = false ..isDocker = false
..isSchedulerRunning = true ..isSchedulerRunning = true

View File

@ -185,7 +185,7 @@ void main({bool isTesting = false}) async {
options.beforeSend = (SentryEvent event, {dynamic hint}) { options.beforeSend = (SentryEvent event, {dynamic hint}) {
final state = store.state; final state = store.state;
final account = state.account; final account = state.account;
final reportErrors = account.reportErrors ?? false; final reportErrors = account.reportErrors;
if (!reportErrors) { if (!reportErrors) {
return null; return null;
@ -194,7 +194,7 @@ void main({bool isTesting = false}) async {
event = event.copyWith( event = event.copyWith(
environment: '${store.state.environment}'.split('.').last, environment: '${store.state.environment}'.split('.').last,
extra: <String, dynamic>{ extra: <String, dynamic>{
'server_version': account.currentVersion ?? 'Unknown', 'server_version': account.currentVersion,
'route': state.uiState.currentRoute, 'route': state.uiState.currentRoute,
}, },
); );

View File

@ -190,8 +190,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
return color.isNotEmpty; return color.isNotEmpty;
} }
bool get showReviewApp => bool get showReviewApp => !prefState.hideReviewApp && company.daysActive > 60;
!prefState.hideReviewApp && company.daysActive > 60;
bool get showOneYearReviewApp => bool get showOneYearReviewApp =>
!prefState.hideOneYearReviewApp && company.daysActive > 365; !prefState.hideOneYearReviewApp && company.daysActive > 365;
@ -222,7 +221,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
String get appVersion { String get appVersion {
String version = 'v'; String version = 'v';
version += account.currentVersion ?? ''; version += account.currentVersion;
if (version.isNotEmpty) { if (version.isNotEmpty) {
version += '-'; version += '-';
@ -826,7 +825,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
} }
} }
bool get reportErrors => account.reportErrors ?? false; bool get reportErrors => account.reportErrors;
bool get isHosted => account == null ? authState.isHosted : account.isHosted; bool get isHosted => account == null ? authState.isHosted : account.isHosted;
@ -1012,7 +1011,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
'\nIs Loading: ${isLoading ? 'Yes' : 'No'}' '\nIs Loading: ${isLoading ? 'Yes' : 'No'}'
'\nIs Saving: ${isSaving ? 'Yes' : 'No'}' '\nIs Saving: ${isSaving ? 'Yes' : 'No'}'
'\nIs Loaded: ${isLoaded ? 'Yes' : 'No'}' '\nIs Loaded: ${isLoaded ? 'Yes' : 'No'}'
'\nis Large: ${(company.isLarge ?? false) ? 'Yes' : 'No'}' '\nis Large: ${(company.isLarge) ? 'Yes' : 'No'}'
'\nCompany: $companyUpdated${userCompanyState.isStale ? ' [S]' : ''}' '\nCompany: $companyUpdated${userCompanyState.isStale ? ' [S]' : ''}'
'\nStatic: $staticUpdated${staticState.isStale ? ' [S]' : ''}' '\nStatic: $staticUpdated${staticState.isStale ? ' [S]' : ''}'
'\nPassword: $passwordUpdated${hasRecentlyEnteredPassword ? '' : ' [S]'}' '\nPassword: $passwordUpdated${hasRecentlyEnteredPassword ? '' : ' [S]'}'

View File

@ -67,7 +67,7 @@ class ClientScreen extends StatelessWidget {
}, },
sortFields: [ sortFields: [
ClientFields.name, ClientFields.name,
ClientFields.idNumber, ClientFields.number,
ClientFields.balance, ClientFields.balance,
ClientFields.updatedAt, ClientFields.updatedAt,
], ],

View File

@ -533,7 +533,7 @@ class _ClientPortalState extends State<ClientPortal>
onChanged: (value) => viewModel.onCompanyChanged( onChanged: (value) => viewModel.onCompanyChanged(
company.rebuild((b) => b..clientCanRegister = value)), company.rebuild((b) => b..clientCanRegister = value)),
), ),
if (state.company.clientCanRegister ?? false) ...[ if (state.company.clientCanRegister) ...[
SizedBox(height: 16), SizedBox(height: 16),
ListTile( ListTile(
title: Text(localization.registrationUrl), title: Text(localization.registrationUrl),

View File

@ -62,7 +62,7 @@ class _ExpenseSettingsState extends State<ExpenseSettings> {
SwitchListTile( SwitchListTile(
activeColor: Theme.of(context).colorScheme.secondary, activeColor: Theme.of(context).colorScheme.secondary,
title: Text(localization.shouldBeInvoiced), title: Text(localization.shouldBeInvoiced),
value: company.markExpensesInvoiceable ?? false, value: company.markExpensesInvoiceable,
subtitle: Text(localization.shouldBeInvoicedHelp), subtitle: Text(localization.shouldBeInvoicedHelp),
onChanged: (value) => viewModel.onCompanyChanged( onChanged: (value) => viewModel.onCompanyChanged(
company.rebuild((b) => b..markExpensesInvoiceable = value)), company.rebuild((b) => b..markExpensesInvoiceable = value)),
@ -70,7 +70,7 @@ class _ExpenseSettingsState extends State<ExpenseSettings> {
SwitchListTile( SwitchListTile(
activeColor: Theme.of(context).colorScheme.secondary, activeColor: Theme.of(context).colorScheme.secondary,
title: Text(localization.markPaid), title: Text(localization.markPaid),
value: company.markExpensesPaid ?? false, value: company.markExpensesPaid,
subtitle: Text(localization.markPaidHelp), subtitle: Text(localization.markPaidHelp),
onChanged: (value) => viewModel.onCompanyChanged( onChanged: (value) => viewModel.onCompanyChanged(
company.rebuild((b) => b..markExpensesPaid = value)), company.rebuild((b) => b..markExpensesPaid = value)),
@ -92,7 +92,7 @@ class _ExpenseSettingsState extends State<ExpenseSettings> {
SwitchListTile( SwitchListTile(
activeColor: Theme.of(context).colorScheme.secondary, activeColor: Theme.of(context).colorScheme.secondary,
title: Text(localization.convertCurrency), title: Text(localization.convertCurrency),
value: company.convertExpenseCurrency ?? false, value: company.convertExpenseCurrency,
subtitle: Text(localization.convertExpenseCurrencyHelp!), subtitle: Text(localization.convertExpenseCurrencyHelp!),
onChanged: (value) => viewModel.onCompanyChanged( onChanged: (value) => viewModel.onCompanyChanged(
company.rebuild((b) => b..convertExpenseCurrency = value)), company.rebuild((b) => b..convertExpenseCurrency = value)),
@ -100,7 +100,7 @@ class _ExpenseSettingsState extends State<ExpenseSettings> {
SwitchListTile( SwitchListTile(
activeColor: Theme.of(context).colorScheme.secondary, activeColor: Theme.of(context).colorScheme.secondary,
title: Text(localization.addDocumentsToInvoice), title: Text(localization.addDocumentsToInvoice),
value: company.invoiceExpenseDocuments ?? false, value: company.invoiceExpenseDocuments,
subtitle: Text(localization.addDocumentsToInvoiceHelp), subtitle: Text(localization.addDocumentsToInvoiceHelp),
onChanged: (value) => viewModel.onCompanyChanged( onChanged: (value) => viewModel.onCompanyChanged(
company.rebuild((b) => b..invoiceExpenseDocuments = value)), company.rebuild((b) => b..invoiceExpenseDocuments = value)),
@ -111,7 +111,7 @@ class _ExpenseSettingsState extends State<ExpenseSettings> {
SwitchListTile( SwitchListTile(
activeColor: Theme.of(context).colorScheme.secondary, activeColor: Theme.of(context).colorScheme.secondary,
title: Text(localization.notifyVendorWhenPaid!), title: Text(localization.notifyVendorWhenPaid!),
value: company.notifyVendorWhenPaid ?? false, value: company.notifyVendorWhenPaid,
subtitle: Text(localization.notifyVendorWhenPaidHelp!), subtitle: Text(localization.notifyVendorWhenPaidHelp!),
onChanged: (value) => viewModel.onCompanyChanged( onChanged: (value) => viewModel.onCompanyChanged(
company.rebuild((b) => b..notifyVendorWhenPaid = value)), company.rebuild((b) => b..notifyVendorWhenPaid = value)),
@ -124,7 +124,7 @@ class _ExpenseSettingsState extends State<ExpenseSettings> {
label: localization.enterTaxes, label: localization.enterTaxes,
enabledLabel: localization.byAmount, enabledLabel: localization.byAmount,
disabledLabel: localization.byRate, disabledLabel: localization.byRate,
value: company.calculateExpenseTaxByAmount ?? false, value: company.calculateExpenseTaxByAmount,
onChanged: (value) => viewModel.onCompanyChanged(company onChanged: (value) => viewModel.onCompanyChanged(company
.rebuild((b) => b..calculateExpenseTaxByAmount = value)), .rebuild((b) => b..calculateExpenseTaxByAmount = value)),
), ),
@ -132,7 +132,7 @@ class _ExpenseSettingsState extends State<ExpenseSettings> {
SwitchListTile( SwitchListTile(
activeColor: Theme.of(context).colorScheme.secondary, activeColor: Theme.of(context).colorScheme.secondary,
title: Text(localization.inclusiveTaxes), title: Text(localization.inclusiveTaxes),
value: company.expenseInclusiveTaxes ?? false, value: company.expenseInclusiveTaxes,
subtitle: Text( subtitle: Text(
'\n${localization.exclusive}: 100 + 10% = 100 + 10\n${localization.inclusive}: 100 + 10% = 90.91 + 9.09'), '\n${localization.exclusive}: 100 + 10% = 100 + 10\n${localization.inclusive}: 100 + 10% = 90.91 + 9.09'),
onChanged: (value) => viewModel.onCompanyChanged( onChanged: (value) => viewModel.onCompanyChanged(

View File

@ -1289,8 +1289,8 @@ class _PdfPreviewState extends State<_PdfPreview> {
entityType: widget.entityType.apiValue, entityType: widget.entityType.apiValue,
settingsType: settingsUIState.entityType.apiValue, settingsType: settingsUIState.entityType.apiValue,
settings: widget.settings!, settings: widget.settings!,
groupId: settingsUIState.group.id ?? '', groupId: settingsUIState.group.id,
clientId: settingsUIState.client.id ?? '', clientId: settingsUIState.client.id,
); );
setState(() => isLoading = true); setState(() => isLoading = true);