Null safety

This commit is contained in:
Hillel Coren 2023-09-20 10:58:07 +03:00
parent 5e490c5d05
commit b328d56c23
10 changed files with 82 additions and 42 deletions

View File

@ -93,7 +93,8 @@ class ReportsScreenVM {
final GroupTotals groupTotals;
final Function(BuildContext, List<String>) onReportColumnsChanged;
final Function(BuildContext) onExportPressed;
final Function(BuildContext, BuiltMap<String?, String?>) onReportFiltersChanged;
final Function(BuildContext, BuiltMap<String?, String?>)
onReportFiltersChanged;
final Function(String?, bool) onReportSorted;
final Function(int, bool) onReportTotalsSorted;
final Function({
@ -471,7 +472,8 @@ class ReportsScreenVM {
getReportColumnType(column, context) ==
ReportColumnType.number)
.toList();
columns.sort((String? str1, String? str2) => str1!.compareTo(str2!));
columns
.sort((String? str1, String? str2) => str1!.compareTo(str2!));
csvData += localization!.lookup(reportState.group)! +
',' +
@ -651,7 +653,7 @@ GroupTotals calculateReportTotals({
final column = columns[j];
if (column == reportState.group) {
totals[group]!['count'] += 1;
totals[group]!['count'] = totals[group]!['count']! + 1;
}
if (cell is ReportNumberValue ||
@ -676,9 +678,9 @@ GroupTotals calculateReportTotals({
fromCurrencyId: cell.currencyId,
toCurrencyId: company.currencyId);
cellValue = round(cellValue * rate, toCurrency.precision);
totals[group]![column] += cellValue;
totals[group]![column] = totals[group]![column]! + cellValue;
} else {
totals[group]![column] += cell.doubleValue!;
totals[group]![column] = totals[group]![column]! + cell.doubleValue!;
}
}
}

View File

@ -129,8 +129,9 @@ class _ScheduleEditState extends State<ScheduleEdit> {
'');
return EditScaffold(
title:
schedule.isNew ? localization!.newSchedule : localization!.editSchedule,
title: schedule.isNew
? localization!.newSchedule
: localization!.editSchedule,
onCancelPressed: (context) => viewModel.onCancelPressed(context),
onSavePressed: (context) => _onSavePressed(),
body: Form(
@ -236,7 +237,8 @@ class _ScheduleEditState extends State<ScheduleEdit> {
labelText: localization.dateRange,
blankValue: null,
value: parameters.dateRange!.isNotEmpty
? DateRange.valueOf(toCamelCase(parameters.dateRange!))
? DateRange.valueOf(
toCamelCase(parameters.dateRange!))
: null,
onChanged: (dynamic value) {
viewModel.onChanged(schedule.rebuild((b) => b
@ -290,8 +292,8 @@ class _ScheduleEditState extends State<ScheduleEdit> {
label: localization.onlyClientsWithInvoices,
value: parameters.onlyClientsWithInvoices,
onChanged: (value) {
viewModel.onChanged(schedule.rebuild(
(b) => b..parameters.onlyClientsWithInvoices = value));
viewModel.onChanged(schedule.rebuild((b) =>
b..parameters.onlyClientsWithInvoices = value));
}),
]),
FormCard(
@ -305,6 +307,9 @@ class _ScheduleEditState extends State<ScheduleEdit> {
clientState: state.clientState,
excludeIds: parameters.clients!.toList(),
onSelected: (value) {
if (value == null) {
return;
}
if (!parameters.clients!.contains(value.id)) {
viewModel.onChanged(schedule.rebuild(
(b) => b..parameters.clients.add(value.id)));
@ -319,8 +324,8 @@ class _ScheduleEditState extends State<ScheduleEdit> {
HelpText(localization.allClients),
for (var clientId in parameters.clients!)
ListTile(
title:
Text(state.clientState.get(clientId)!.displayName),
title: Text(
state.clientState.get(clientId)!.displayName),
trailing: IconButton(
icon: Icon(Icons.clear),
onPressed: () {

View File

@ -43,9 +43,9 @@ class ScheduleListItem extends StatelessWidget {
String subtitle = formatDate(schedule!.nextRun, context);
String? title = localization.lookup(schedule!.template);
String title = localization.lookup(schedule!.template) ?? '';
if (schedule!.template == ScheduleEntity.TEMPLATE_EMAIL_RECORD) {
final entityType = EntityType.valueOf(schedule!.parameters.entityType);
final entityType = EntityType.valueOf(schedule!.parameters.entityType!);
final entity =
state.getEntityMap(entityType)![schedule!.parameters.entityId];
@ -87,7 +87,8 @@ class ScheduleListItem extends StatelessWidget {
child: Container(
width: MediaQuery.of(context).size.width,
child: ListTile(
onTap: () => onTap != null ? onTap!() : selectEntity(entity: schedule!),
onTap: () =>
onTap != null ? onTap!() : selectEntity(entity: schedule!),
onLongPress: () => onLongPress != null
? onLongPress!()
: selectEntity(entity: schedule!, longPress: true),

View File

@ -36,8 +36,9 @@ class _ScheduleViewState extends State<ScheduleView> {
BaseEntity? entity;
if (schedule.template == ScheduleEntity.TEMPLATE_EMAIL_RECORD) {
final entityType = EntityType.valueOf(schedule.parameters.entityType);
entity = state.getEntityMap(entityType)![schedule.parameters.entityId] as BaseEntity?;
final entityType = EntityType.valueOf(schedule.parameters.entityType!);
entity = state.getEntityMap(entityType)![schedule.parameters.entityId]
as BaseEntity?;
}
return ViewScaffold(
@ -86,7 +87,9 @@ class _ScheduleViewState extends State<ScheduleView> {
localization.showPaymentsTable: parameters.showPaymentsTable!
? localization.yes
: localization.no,
localization.onlyClientsWithInvoices: (parameters.onlyClientsWithInvoices != null && parameters.onlyClientsWithInvoices!)
localization.onlyClientsWithInvoices:
(parameters.onlyClientsWithInvoices != null &&
parameters.onlyClientsWithInvoices!)
? localization.yes
: localization.no,
localization.status: localization.lookup(parameters.status),

View File

@ -46,9 +46,11 @@ Completer<T> snackBarCompleter<T>(
Completer<Null> popCompleter(BuildContext context, dynamic result) {
final Completer<Null> completer = Completer<Null>();
completer.future.then((_) {
completer.future
.then<Null>(() {
Navigator.of(context).pop<dynamic>(result);
} as FutureOr<_> Function(Null)).catchError((Object error) {
} as FutureOr<Null> Function(Null))
.catchError((Object error) {
showDialog<ErrorDialog>(
context: navigatorKey.currentContext!,
builder: (BuildContext context) {

View File

@ -419,7 +419,7 @@ class _FieldConfirmationState extends State<FieldConfirmation> {
maxLengthEnforcement: widget.maxLength != null
? MaxLengthEnforcement.enforced
: MaxLengthEnforcement.none,
buildCounter: (_, {currentLength, maxLength, isFocused}) => null,
//buildCounter: (_, {currentLength, maxLength, isFocused}) => null,
decoration: InputDecoration(
labelText: widget.field,
),

View File

@ -1,3 +1,4 @@
/*
// DELETE THIS FILE ONCE SUPER EDITOR IS UPDATED
import 'dart:convert';
@ -587,3 +588,4 @@ class _EmptyParagraphSyntax extends md.BlockSyntax {
return md.Element('p', []);
}
}
*/

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:invoiceninja_flutter/utils/markdown.dart';
import 'package:invoiceninja_flutter/utils/super_editor/toolbar.dart';
import 'package:super_editor/super_editor.dart';
import 'package:super_editor_markdown/super_editor_markdown.dart';
/// Example of a rich text editor.
///

View File

@ -45,10 +45,10 @@ packages:
dependency: transitive
description:
name: attributed_text
sha256: "892b9517ba27f78ebee526424a91d1aba44d729e610f06a0dd9a3a43d3d81f6d"
sha256: e43495051b63e6cdbe96aa62123974074cca109d9c56f74ce2ffaec8060e044e
url: "https://pub.dev"
source: hosted
version: "0.2.1"
version: "0.2.2"
barcode:
dependency: transitive
description:
@ -466,6 +466,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
follow_the_leader:
dependency: transitive
description:
name: follow_the_leader
sha256: "44396bad4abbf0d43d5ca3ee98180772bb45a78f39a1960c62170843bd46753f"
url: "https://pub.dev"
source: hosted
version: "0.0.4+3"
frontend_server_client:
dependency: transitive
description:
@ -808,13 +816,13 @@ packages:
source: hosted
version: "1.0.2"
markdown:
dependency: "direct main"
dependency: transitive
description:
name: markdown
sha256: "39caf989ccc72c63e87b961851a74257141938599ed2db45fbd9403fee0db423"
sha256: "01512006c8429f604eb10f9848717baeaedf99e991d14a50d540d9beff08e5c6"
url: "https://pub.dev"
source: hosted
version: "5.0.0"
version: "4.0.1"
matcher:
dependency: transitive
description:
@ -911,6 +919,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.3.1"
overlord:
dependency: transitive
description:
name: overlord
sha256: "7fa6a83455b7da5c66a16320c02783d110c574a6e6c511750c662dbadfe9399f"
url: "https://pub.dev"
source: hosted
version: "0.0.3+2"
package_config:
dependency: transitive
description:
@ -1456,20 +1472,27 @@ packages:
super_editor:
dependency: "direct main"
description:
path: super_editor
ref: HEAD
resolved-ref: e4eceea4a72706410a1e910ad0ce01b815c63a8e
url: "https://github.com/superlistapp/super_editor.git"
source: git
version: "0.2.3-dev.1"
name: super_editor
sha256: "2d5acf95449f53eec1c7d0788530b3a667758224a1e4aa4164bd5d6c0d159bab"
url: "https://pub.dev"
source: hosted
version: "0.2.6"
super_editor_markdown:
dependency: "direct main"
description:
name: super_editor_markdown
sha256: "2515d0183ee21aa22d577e95e80b1e4bc1b9ce0f651127d40844be7cb58b5330"
url: "https://pub.dev"
source: hosted
version: "0.1.5"
super_text_layout:
dependency: transitive
description:
name: super_text_layout
sha256: "6cf41a07780d7e40cec56ed3dcde59b527968a4e282b78e2d7e9a0134b26685c"
sha256: "8afed48db5e15c9c3488ca9f24b24cd24a4867a6d9d2dd2ba540ac363f50b60d"
url: "https://pub.dev"
source: hosted
version: "0.1.4"
version: "0.1.6"
sync_http:
dependency: transitive
description:

View File

@ -69,12 +69,13 @@ dependencies:
contacts_service: ^0.6.3
diacritic: ^0.1.3
states_rebuilder: ^6.2.0
# super_editor: ^0.2.2
markdown: ^5.0.0 # REMOVE THIS
super_editor:
git:
url: https://github.com/superlistapp/super_editor.git
path: super_editor
super_editor: ^0.2.6
super_editor_markdown: ^0.1.5
#markdown: ^5.0.0 # REMOVE THIS
#super_editor:
# git:
# url: https://github.com/superlistapp/super_editor.git
# path: super_editor
html2md: ^1.2.6
printing: ^5.10.1
image_cropper: ^3.0.1