Null safety
This commit is contained in:
parent
43212776da
commit
66c320cfd4
|
|
@ -64,7 +64,7 @@ class _CustomFieldState extends State<CustomField> {
|
||||||
final localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
final fieldLabel = company.getCustomFieldLabel(widget.field);
|
final fieldLabel = company.getCustomFieldLabel(widget.field);
|
||||||
|
|
||||||
if ((fieldLabel).isEmpty) {
|
if (fieldLabel.isEmpty) {
|
||||||
return SizedBox();
|
return SizedBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,7 @@ class _DatePickerState extends State<DatePicker> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((date).isNotEmpty) {
|
if (date.isNotEmpty) {
|
||||||
widget.onSelected(date, true);
|
widget.onSelected(date, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class LearnMoreUrl extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
if ((url).isEmpty) {
|
if (url.isEmpty) {
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ class _InvoiceEmailViewState extends State<InvoiceEmailView>
|
||||||
selectedTemplate = EmailTemplate.reminder3;
|
selectedTemplate = EmailTemplate.reminder3;
|
||||||
else if ((invoice.reminder1Sent ?? '').isNotEmpty)
|
else if ((invoice.reminder1Sent ?? '').isNotEmpty)
|
||||||
selectedTemplate = EmailTemplate.reminder2;
|
selectedTemplate = EmailTemplate.reminder2;
|
||||||
else if ((invoice.lastSentDate ?? '').isNotEmpty)
|
else if ((invoice.lastSentDate).isNotEmpty)
|
||||||
selectedTemplate = EmailTemplate.reminder1;
|
selectedTemplate = EmailTemplate.reminder1;
|
||||||
else
|
else
|
||||||
selectedTemplate = EmailTemplate.invoice;
|
selectedTemplate = EmailTemplate.invoice;
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ class ActivityListTile extends StatelessWidget {
|
||||||
subtitle: Row(
|
subtitle: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(((activity.notes ?? '').isNotEmpty
|
child: Text(((activity.notes).isNotEmpty
|
||||||
? localization.lookup(activity.notes)!.trim() + '\n'
|
? localization.lookup(activity.notes)!.trim() + '\n'
|
||||||
: '') +
|
: '') +
|
||||||
formatDate(
|
formatDate(
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ class _DropDownMultiSelectState extends State<DropDownMultiSelect> {
|
||||||
? widget.selectedValues
|
? widget.selectedValues
|
||||||
.map((dynamic e) => e.toString())
|
.map((dynamic e) => e.toString())
|
||||||
.reduce((a, b) => a + ' , ' + b)
|
.reduce((a, b) => a + ' , ' + b)
|
||||||
: widget.whenEmpty ?? ''),
|
: widget.whenEmpty),
|
||||||
),
|
),
|
||||||
alignment: Alignment.centerLeft),
|
alignment: Alignment.centerLeft),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class EntityPresenter {
|
||||||
var name = entity.listDisplayName;
|
var name = entity.listDisplayName;
|
||||||
|
|
||||||
// TODO replace with this: https://github.com/flutter/flutter/issues/45336
|
// TODO replace with this: https://github.com/flutter/flutter/issues/45336
|
||||||
if ((name ?? '').isEmpty) {
|
if ((name).isEmpty) {
|
||||||
name = localization.pending;
|
name = localization.pending;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -227,8 +227,7 @@ class AppPaginatedDataTableState extends State<AppPaginatedDataTable> {
|
||||||
super.initState();
|
super.initState();
|
||||||
_controller = ScrollController();
|
_controller = ScrollController();
|
||||||
_firstRowIndex = PageStorage.of(context).readState(context) as int? ??
|
_firstRowIndex = PageStorage.of(context).readState(context) as int? ??
|
||||||
widget.initialFirstRowIndex ??
|
widget.initialFirstRowIndex;
|
||||||
0;
|
|
||||||
widget.source.addListener(_handleDataSourceChanged);
|
widget.source.addListener(_handleDataSourceChanged);
|
||||||
_handleDataSourceChanged();
|
_handleDataSourceChanged();
|
||||||
}
|
}
|
||||||
|
|
@ -298,7 +297,7 @@ class AppPaginatedDataTableState extends State<AppPaginatedDataTable> {
|
||||||
if (index < _rowCount || _rowCountApproximate) {
|
if (index < _rowCount || _rowCountApproximate) {
|
||||||
row = _rows.putIfAbsent(index, () => widget.source.getRow(index));
|
row = _rows.putIfAbsent(index, () => widget.source.getRow(index));
|
||||||
if (row == null && !haveProgressIndicator) {
|
if (row == null && !haveProgressIndicator) {
|
||||||
row ??= _getProgressIndicatorRowFor(index);
|
row = _getProgressIndicatorRowFor(index);
|
||||||
haveProgressIndicator = true;
|
haveProgressIndicator = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class RecurringInvoiceListItem extends StatelessWidget {
|
||||||
this.showCheckbox = true,
|
this.showCheckbox = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
final InvoiceEntity? invoice;
|
final InvoiceEntity invoice;
|
||||||
final String? filter;
|
final String? filter;
|
||||||
final bool showCheckbox;
|
final bool showCheckbox;
|
||||||
|
|
||||||
|
|
@ -33,38 +33,38 @@ class RecurringInvoiceListItem extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final store = StoreProvider.of<AppState>(context);
|
final store = StoreProvider.of<AppState>(context);
|
||||||
final state = store.state;
|
final state = store.state;
|
||||||
final client = state.clientState.get(invoice!.clientId);
|
final client = state.clientState.get(invoice.clientId);
|
||||||
final uiState = state.uiState;
|
final uiState = state.uiState;
|
||||||
final invoiceUIState = uiState.recurringInvoiceUIState;
|
final invoiceUIState = uiState.recurringInvoiceUIState;
|
||||||
final listUIState = state.getUIState(invoice!.entityType)!.listUIState;
|
final listUIState = state.getUIState(invoice.entityType)!.listUIState;
|
||||||
final isInMultiselect = showCheckbox && listUIState.isInMultiselect();
|
final isInMultiselect = showCheckbox && listUIState.isInMultiselect();
|
||||||
final isChecked = isInMultiselect && listUIState.isSelected(invoice!.id);
|
final isChecked = isInMultiselect && listUIState.isSelected(invoice.id);
|
||||||
final textStyle = TextStyle(fontSize: 16);
|
final textStyle = TextStyle(fontSize: 16);
|
||||||
final localization = AppLocalization.of(context)!;
|
final localization = AppLocalization.of(context)!;
|
||||||
final filterMatch = filter != null && filter!.isNotEmpty
|
final filterMatch = filter != null && filter!.isNotEmpty
|
||||||
? (invoice!.matchesFilterValue(filter) ??
|
? (invoice.matchesFilterValue(filter) ??
|
||||||
client!.matchesFilterValue(filter))
|
client!.matchesFilterValue(filter))
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
final statusLabel = localization
|
final statusLabel = localization
|
||||||
.lookup(kRecurringInvoiceStatuses[invoice!.calculatedStatusId]);
|
.lookup(kRecurringInvoiceStatuses[invoice.calculatedStatusId]);
|
||||||
final statusColor =
|
final statusColor =
|
||||||
RecurringInvoiceStatusColors(state.prefState.colorThemeModel)
|
RecurringInvoiceStatusColors(state.prefState.colorThemeModel)
|
||||||
.colors[invoice!.calculatedStatusId];
|
.colors[invoice.calculatedStatusId];
|
||||||
final textColor = Theme.of(context).textTheme.bodyLarge!.color;
|
final textColor = Theme.of(context).textTheme.bodyLarge!.color;
|
||||||
|
|
||||||
String subtitle = '';
|
String subtitle = '';
|
||||||
if (invoice!.nextSendDate.isNotEmpty) {
|
if (invoice.nextSendDate.isNotEmpty) {
|
||||||
subtitle += formatDate(invoice!.nextSendDate, context);
|
subtitle += formatDate(invoice.nextSendDate, context);
|
||||||
}
|
}
|
||||||
if (subtitle.isNotEmpty) {
|
if (subtitle.isNotEmpty) {
|
||||||
subtitle += ' • ';
|
subtitle += ' • ';
|
||||||
}
|
}
|
||||||
subtitle += localization.lookup(kFrequencies[invoice!.frequencyId])!;
|
subtitle += localization.lookup(kFrequencies[invoice.frequencyId])!;
|
||||||
|
|
||||||
return DismissibleEntity(
|
return DismissibleEntity(
|
||||||
isSelected: isDesktop(context) &&
|
isSelected: isDesktop(context) &&
|
||||||
invoice!.id ==
|
invoice.id ==
|
||||||
(uiState.isEditing
|
(uiState.isEditing
|
||||||
? invoiceUIState.editing!.id
|
? invoiceUIState.editing!.id
|
||||||
: invoiceUIState.selectedId),
|
: invoiceUIState.selectedId),
|
||||||
|
|
@ -76,11 +76,11 @@ class RecurringInvoiceListItem extends StatelessWidget {
|
||||||
return constraints.maxWidth > kTableListWidthCutoff
|
return constraints.maxWidth > kTableListWidthCutoff
|
||||||
? InkWell(
|
? InkWell(
|
||||||
onTap: () => selectEntity(
|
onTap: () => selectEntity(
|
||||||
entity: invoice!,
|
entity: invoice,
|
||||||
forceView: !showCheckbox,
|
forceView: !showCheckbox,
|
||||||
),
|
),
|
||||||
onLongPress: () =>
|
onLongPress: () =>
|
||||||
selectEntity(entity: invoice!, longPress: true),
|
selectEntity(entity: invoice, longPress: true),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 10,
|
left: 10,
|
||||||
|
|
@ -106,7 +106,7 @@ class RecurringInvoiceListItem extends StatelessWidget {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: ActionMenuButton(
|
: ActionMenuButton(
|
||||||
entityActions: invoice!.getActions(
|
entityActions: invoice.getActions(
|
||||||
userCompany: state.userCompany,
|
userCompany: state.userCompany,
|
||||||
client: client,
|
client: client,
|
||||||
includeEdit: true,
|
includeEdit: true,
|
||||||
|
|
@ -122,13 +122,13 @@ class RecurringInvoiceListItem extends StatelessWidget {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
Text(
|
||||||
(invoice!.number ?? '').isEmpty
|
(invoice.number).isEmpty
|
||||||
? localization.pending
|
? localization.pending
|
||||||
: invoice!.number,
|
: invoice.number,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
if (!invoice!.isActive) EntityStateLabel(invoice)
|
if (!invoice.isActive) EntityStateLabel(invoice)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -139,7 +139,7 @@ class RecurringInvoiceListItem extends StatelessWidget {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
Text(
|
||||||
client!.displayName +
|
client!.displayName +
|
||||||
(invoice!.documents.isNotEmpty
|
(invoice.documents.isNotEmpty
|
||||||
? ' 📎'
|
? ' 📎'
|
||||||
: ''),
|
: ''),
|
||||||
style: textStyle),
|
style: textStyle),
|
||||||
|
|
@ -160,7 +160,7 @@ class RecurringInvoiceListItem extends StatelessWidget {
|
||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
Text(
|
Text(
|
||||||
formatNumber(invoice!.amount, context,
|
formatNumber(invoice.amount, context,
|
||||||
clientId: client.id)!,
|
clientId: client.id)!,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
|
|
@ -173,9 +173,9 @@ class RecurringInvoiceListItem extends StatelessWidget {
|
||||||
)
|
)
|
||||||
: ListTile(
|
: ListTile(
|
||||||
onTap: () =>
|
onTap: () =>
|
||||||
selectEntity(entity: invoice!, forceView: !showCheckbox),
|
selectEntity(entity: invoice, forceView: !showCheckbox),
|
||||||
onLongPress: () =>
|
onLongPress: () =>
|
||||||
selectEntity(entity: invoice!, longPress: true),
|
selectEntity(entity: invoice, longPress: true),
|
||||||
leading: isInMultiselect
|
leading: isInMultiselect
|
||||||
? IgnorePointer(
|
? IgnorePointer(
|
||||||
ignoring: listUIState.isInMultiselect(),
|
ignoring: listUIState.isInMultiselect(),
|
||||||
|
|
@ -202,8 +202,8 @@ class RecurringInvoiceListItem extends StatelessWidget {
|
||||||
),
|
),
|
||||||
SizedBox(width: 4),
|
SizedBox(width: 4),
|
||||||
Text(
|
Text(
|
||||||
formatNumber(invoice!.amount, context,
|
formatNumber(invoice.amount, context,
|
||||||
clientId: invoice!.clientId)!,
|
clientId: invoice.clientId)!,
|
||||||
style: Theme.of(context).textTheme.titleMedium),
|
style: Theme.of(context).textTheme.titleMedium),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
@ -216,15 +216,15 @@ class RecurringInvoiceListItem extends StatelessWidget {
|
||||||
Expanded(
|
Expanded(
|
||||||
child: filterMatch == null
|
child: filterMatch == null
|
||||||
? Text(
|
? Text(
|
||||||
(((invoice!.number ?? '').isEmpty
|
(((invoice.number ?? '').isEmpty
|
||||||
? localization.pending
|
? localization.pending
|
||||||
: invoice!.number) +
|
: invoice.number) +
|
||||||
(invoice!.nextSendDate.isNotEmpty
|
(invoice.nextSendDate.isNotEmpty
|
||||||
? ' • '
|
? ' • '
|
||||||
: '') +
|
: '') +
|
||||||
formatDate(invoice!.nextSendDate,
|
formatDate(invoice.nextSendDate,
|
||||||
context) +
|
context) +
|
||||||
(invoice!.documents.isNotEmpty
|
(invoice.documents.isNotEmpty
|
||||||
? ' 📎'
|
? ' 📎'
|
||||||
: ''))
|
: ''))
|
||||||
.trim(),
|
.trim(),
|
||||||
|
|
@ -238,7 +238,7 @@ class RecurringInvoiceListItem extends StatelessWidget {
|
||||||
Text(statusLabel!,
|
Text(statusLabel!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color:
|
||||||
!invoice!.isSent ? textColor : statusColor,
|
!invoice.isSent ? textColor : statusColor,
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class RecurringInvoiceListBuilder extends StatelessWidget {
|
||||||
itemBuilder: (BuildContext context, index) {
|
itemBuilder: (BuildContext context, index) {
|
||||||
final recurringInvoiceId = viewModel.recurringInvoiceList[index];
|
final recurringInvoiceId = viewModel.recurringInvoiceList[index];
|
||||||
final recurringInvoice =
|
final recurringInvoice =
|
||||||
viewModel.recurringInvoiceMap[recurringInvoiceId];
|
viewModel.recurringInvoiceMap[recurringInvoiceId]!;
|
||||||
|
|
||||||
return RecurringInvoiceListItem(
|
return RecurringInvoiceListItem(
|
||||||
filter: viewModel.filter,
|
filter: viewModel.filter,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue