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
static void _initializeBuilder(AccountEntityBuilder builder) => builder
..key = ''
..currentVersion = ''
..debugEnabled = false
..isDocker = false
..isSchedulerRunning = true

View File

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

View File

@ -190,8 +190,7 @@ 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;
@ -222,7 +221,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
String get appVersion {
String version = 'v';
version += account.currentVersion ?? '';
version += account.currentVersion;
if (version.isNotEmpty) {
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;
@ -1012,7 +1011,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
'\nIs Loading: ${isLoading ? 'Yes' : 'No'}'
'\nIs Saving: ${isSaving ? '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]' : ''}'
'\nStatic: $staticUpdated${staticState.isStale ? ' [S]' : ''}'
'\nPassword: $passwordUpdated${hasRecentlyEnteredPassword ? '' : ' [S]'}'

View File

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

View File

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

View File

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

View File

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