Null safety
This commit is contained in:
parent
818e39a0e8
commit
85a2840569
|
|
@ -30,7 +30,7 @@ class DesignPicker extends StatelessWidget {
|
|||
|
||||
return AppDropdownButton<String>(
|
||||
value: initialValue,
|
||||
onChanged: (dynamic value) => onSelected(designState.map[value]),
|
||||
onChanged: (dynamic value) => onSelected(designState.map[value]!),
|
||||
items: designState.list
|
||||
.where((designId) {
|
||||
final design = designState.map[designId];
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class TaxRateDropdown extends StatefulWidget {
|
|||
}) : super(key: key);
|
||||
|
||||
final String? labelText;
|
||||
final Function(TaxRateEntity?) onSelected;
|
||||
final Function(TaxRateEntity) onSelected;
|
||||
final String? initialTaxName;
|
||||
final double? initialTaxRate;
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class InvoiceEditContacts extends StatelessWidget {
|
|||
invoice: invoice,
|
||||
invitation: invitation,
|
||||
onTap: () => invitation == null
|
||||
? viewModel.onAddVendorContact(contact)
|
||||
? viewModel.onAddVendorContact(contact!)
|
||||
: viewModel.onRemoveContact(invitation),
|
||||
);
|
||||
}).toList(),
|
||||
|
|
@ -97,7 +97,7 @@ class InvoiceEditContacts extends StatelessWidget {
|
|||
invoice: invoice,
|
||||
invitation: invitation,
|
||||
onTap: () => invitation == null
|
||||
? viewModel.onAddClientContact(contact)
|
||||
? viewModel.onAddClientContact(contact!)
|
||||
: viewModel.onRemoveContact(invitation),
|
||||
);
|
||||
}).toList(),
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ class EntityEditContactsVM {
|
|||
final InvoiceEntity? invoice;
|
||||
final ClientEntity? client;
|
||||
final VendorEntity? vendor;
|
||||
final Function(ClientContactEntity?) onAddClientContact;
|
||||
final Function(VendorContactEntity?) onAddVendorContact;
|
||||
final Function(ClientContactEntity) onAddClientContact;
|
||||
final Function(VendorContactEntity) onAddVendorContact;
|
||||
final Function(InvitationEntity) onRemoveContact;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
|||
|
||||
// Package imports:
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/client_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/vendor_model.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/invoice/invoice_actions.dart';
|
||||
|
|
@ -304,8 +305,8 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
clientId: invoice.clientId,
|
||||
clientState: state.clientState,
|
||||
onSelected: (client) {
|
||||
viewModel.onClientChanged!(
|
||||
context, invoice, client as ClientEntity?);
|
||||
viewModel.onClientChanged!(context, invoice,
|
||||
client as ClientEntity?);
|
||||
},
|
||||
onAddPressed: (completer) => viewModel
|
||||
.onAddClientPressed!(context, completer),
|
||||
|
|
@ -370,8 +371,8 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
items: kFrequencies.entries
|
||||
.map((entry) => DropdownMenuItem(
|
||||
value: entry.key,
|
||||
child: Text(
|
||||
localization.lookup(entry.value)!),
|
||||
child: Text(localization
|
||||
.lookup(entry.value)!),
|
||||
))
|
||||
.toList()),
|
||||
DatePicker(
|
||||
|
|
@ -389,8 +390,8 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
labelText: localization.remainingCycles,
|
||||
value: invoice.remainingCycles,
|
||||
blankValue: null,
|
||||
onChanged: (dynamic value) => viewModel.onChanged!(
|
||||
invoice.rebuild(
|
||||
onChanged: (dynamic value) =>
|
||||
viewModel.onChanged!(invoice.rebuild(
|
||||
(b) => b..remainingCycles = value)),
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
|
|
@ -570,7 +571,8 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
.map((type) =>
|
||||
Text(localization.lookup(type)!))
|
||||
.toList(),
|
||||
onChanged: (dynamic value) => viewModel.onChanged!(
|
||||
onChanged: (dynamic value) => viewModel
|
||||
.onChanged!(
|
||||
invoice.rebuild((b) => b..autoBill = value)),
|
||||
items: [
|
||||
SettingsEntity.AUTO_BILL_ALWAYS,
|
||||
|
|
@ -800,8 +802,8 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
UserPicker(
|
||||
userId: invoice.assignedUserId,
|
||||
onChanged: (userId) => viewModel
|
||||
.onChanged!(invoice.rebuild((b) =>
|
||||
b..assignedUserId = userId)),
|
||||
.onChanged!(invoice.rebuild((b) => b
|
||||
..assignedUserId = userId)),
|
||||
),
|
||||
if (company
|
||||
.isModuleEnabled(EntityType.project))
|
||||
|
|
@ -836,8 +838,8 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
clientId: invoice.clientId,
|
||||
clientState: state.clientState,
|
||||
onSelected: (client) {
|
||||
viewModel.onChanged!(invoice.rebuild(
|
||||
(b) => b
|
||||
viewModel.onChanged!(
|
||||
invoice.rebuild((b) => b
|
||||
..clientId =
|
||||
client?.id ?? ''));
|
||||
},
|
||||
|
|
@ -876,8 +878,7 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
FormatNumberType.inputMoney),
|
||||
onChanged: (value) => viewModel
|
||||
.onChanged!(invoice.rebuild((b) => b
|
||||
..exchangeRate =
|
||||
parseDouble(value))),
|
||||
..exchangeRate = parseDouble(value))),
|
||||
keyboardType:
|
||||
TextInputType.numberWithOptions(
|
||||
decimal: true),
|
||||
|
|
@ -905,8 +906,8 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
value: invoice
|
||||
.usesInclusiveTaxes,
|
||||
onChanged: (value) {
|
||||
viewModel.onChanged!(invoice
|
||||
.rebuild((b) => b
|
||||
viewModel.onChanged!(
|
||||
invoice.rebuild((b) => b
|
||||
..usesInclusiveTaxes =
|
||||
value));
|
||||
},
|
||||
|
|
@ -932,8 +933,8 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
value:
|
||||
invoice.autoBillEnabled,
|
||||
onChanged: (value) {
|
||||
viewModel.onChanged!(invoice
|
||||
.rebuild((b) => b
|
||||
viewModel.onChanged!(
|
||||
invoice.rebuild((b) => b
|
||||
..autoBillEnabled =
|
||||
value));
|
||||
},
|
||||
|
|
@ -955,8 +956,8 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
originalInvoice.documents.toList(),
|
||||
onUploadDocument: (path, isPrivate) =>
|
||||
widget.entityViewModel
|
||||
.onUploadDocuments!(
|
||||
context, path, isPrivate),
|
||||
.onUploadDocuments!(
|
||||
context, path, isPrivate),
|
||||
onRenamedDocument: () => store.dispatch(
|
||||
LoadInvoice(invoiceId: invoice.id)),
|
||||
)
|
||||
|
|
@ -1030,8 +1031,8 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
invoice.taxName1.isNotEmpty)
|
||||
TaxRateDropdown(
|
||||
onSelected: (taxRate) {
|
||||
viewModel
|
||||
.onChanged!(invoice.applyTax(taxRate));
|
||||
viewModel.onChanged!(
|
||||
invoice.applyTax(taxRate!));
|
||||
},
|
||||
labelText: localization.tax +
|
||||
(company.settings.enableInclusiveTaxes!
|
||||
|
|
@ -1045,7 +1046,7 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
TaxRateDropdown(
|
||||
onSelected: (taxRate) {
|
||||
viewModel.onChanged!(invoice
|
||||
.applyTax(taxRate, isSecond: true));
|
||||
.applyTax(taxRate!, isSecond: true));
|
||||
},
|
||||
labelText: localization.tax +
|
||||
(company.settings.enableInclusiveTaxes!
|
||||
|
|
@ -1059,9 +1060,7 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
TaxRateDropdown(
|
||||
onSelected: (taxRate) {
|
||||
final updatedInvoice = invoice
|
||||
.applyTax(taxRate, isThird: true);
|
||||
print(
|
||||
'## UPDATED\nRate 3: ${updatedInvoice.taxName3} => ${updatedInvoice.taxRate3}');
|
||||
.applyTax(taxRate!, isThird: true);
|
||||
viewModel.onChanged!(invoice
|
||||
.applyTax(taxRate, isThird: true));
|
||||
},
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ class InvoiceEditDetailsState extends State<InvoiceEditDetails> {
|
|||
invoice.taxName1.isNotEmpty)
|
||||
TaxRateDropdown(
|
||||
onSelected: (taxRate) =>
|
||||
viewModel.onChanged!(invoice.applyTax(taxRate)),
|
||||
viewModel.onChanged!(invoice.applyTax(taxRate!)),
|
||||
labelText: localization.tax +
|
||||
(company.settings.enableInclusiveTaxes!
|
||||
? ' - ${localization.inclusive}'
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ class _ImportExportState extends State<ImportExport> {
|
|||
)
|
||||
else
|
||||
_FileMapper(
|
||||
key: ValueKey(_response.hash),
|
||||
key: ValueKey(_response!.hash),
|
||||
importType: _importFormat,
|
||||
formKey: _formKey,
|
||||
response: _response,
|
||||
|
|
@ -220,8 +220,8 @@ class _ImportExportState extends State<ImportExport> {
|
|||
]
|
||||
.map((importType) => DropdownMenuItem<ImportType>(
|
||||
value: importType,
|
||||
child:
|
||||
Text(localization.lookup('$importType')!)))
|
||||
child: Text(
|
||||
localization.lookup('$importType')!)))
|
||||
.toList()),
|
||||
),
|
||||
),
|
||||
|
|
@ -253,7 +253,8 @@ class _ImportExportState extends State<ImportExport> {
|
|||
items: DATE_FIELDS[_exportType]!
|
||||
.map((dateField) => DropdownMenuItem<String>(
|
||||
value: dateField,
|
||||
child: Text(localization.lookup('$dateField')!)))
|
||||
child:
|
||||
Text(localization.lookup('$dateField')!)))
|
||||
.toList(),
|
||||
),
|
||||
if (_exportDate.isNotEmpty)
|
||||
|
|
@ -777,7 +778,7 @@ class __FileMapperState extends State<_FileMapper> {
|
|||
setState(() => _isLoading = true);
|
||||
|
||||
final importRequest = ImportRequest(
|
||||
hash: widget.response.hash,
|
||||
hash: widget.response!.hash,
|
||||
skipHeader: _useFirstRowAsHeaders,
|
||||
columnMap: BuiltMap(convertedMapping),
|
||||
importType: widget.importType.name,
|
||||
|
|
@ -862,7 +863,8 @@ class _FieldMapper extends StatelessWidget {
|
|||
isExpanded: true,
|
||||
value: available.contains(mappedTo) ? mappedTo : null,
|
||||
validator: (value) => (value ?? '').isNotEmpty &&
|
||||
mapping!.values.where((element) => element == value).length > 1
|
||||
mapping!.values.where((element) => element == value).length >
|
||||
1
|
||||
? localization!.duplicateColumnMapping
|
||||
: null,
|
||||
onChanged: onMappedToChanged as void Function(String?)?,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
// Flutter imports:
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
// Package imports:
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/purchase_order_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/quote_model.dart';
|
||||
|
|
@ -144,7 +146,9 @@ class _InvoiceDesignState extends State<InvoiceDesign>
|
|||
..companyLogoSize = logoSize.isEmpty
|
||||
? ''
|
||||
: logoSize +
|
||||
(viewModel.settings.companyLogoSize!.contains('px') ? 'px' : '%'));
|
||||
(viewModel.settings.companyLogoSize!.contains('px')
|
||||
? 'px'
|
||||
: '%'));
|
||||
if (settings != viewModel.settings) {
|
||||
_debouncer.run(() {
|
||||
viewModel.onSettingsChanged(settings);
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
|
|||
onSelected: (value) {
|
||||
final parts = subscription.recurringProductIds.split(',');
|
||||
viewModel.onChanged(subscription.rebuild((b) => b
|
||||
..recurringProductIds = <String>[...parts, value.id]
|
||||
..recurringProductIds = <String>[...parts, value!.id]
|
||||
.where((part) => part.isNotEmpty)
|
||||
.join(',')));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue