Null safety
This commit is contained in:
parent
afafdc305c
commit
ca45cb39a4
|
|
@ -688,8 +688,8 @@ Future handleCreditAction(BuildContext context, List<BaseEntity?> credits,
|
||||||
final invitation = credit.invitations.first;
|
final invitation = credit.invitations.first;
|
||||||
final url = invitation.downloadLink;
|
final url = invitation.downloadLink;
|
||||||
store.dispatch(StartSaving());
|
store.dispatch(StartSaving());
|
||||||
final http.Response? response = await (WebClient()
|
final http.Response? response =
|
||||||
.get(url, '', rawResponse: true) as FutureOr<Response?>);
|
await (WebClient().get(url, '', rawResponse: true));
|
||||||
store.dispatch(StopSaving());
|
store.dispatch(StopSaving());
|
||||||
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
||||||
break;
|
break;
|
||||||
|
|
@ -699,8 +699,7 @@ Future handleCreditAction(BuildContext context, List<BaseEntity?> credits,
|
||||||
final data = json.encode(
|
final data = json.encode(
|
||||||
{'ids': creditIds, 'action': EntityAction.bulkPrint.toApiParam()});
|
{'ids': creditIds, 'action': EntityAction.bulkPrint.toApiParam()});
|
||||||
final http.Response? response = await (WebClient()
|
final http.Response? response = await (WebClient()
|
||||||
.post(url, state.credentials.token, data: data, rawResponse: true)
|
.post(url, state.credentials.token, data: data, rawResponse: true));
|
||||||
as FutureOr<Response?>);
|
|
||||||
store.dispatch(StopSaving());
|
store.dispatch(StopSaving());
|
||||||
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -842,8 +842,8 @@ void handleInvoiceAction(BuildContext? context, List<BaseEntity?> invoices,
|
||||||
final invitation = invoice.invitations.first;
|
final invitation = invoice.invitations.first;
|
||||||
final url = invitation.downloadLink;
|
final url = invitation.downloadLink;
|
||||||
store.dispatch(StartSaving());
|
store.dispatch(StartSaving());
|
||||||
final http.Response? response = await (WebClient()
|
final http.Response? response =
|
||||||
.get(url, '', rawResponse: true) as FutureOr<Response?>);
|
await (WebClient().get(url, '', rawResponse: true));
|
||||||
store.dispatch(StopSaving());
|
store.dispatch(StopSaving());
|
||||||
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
||||||
break;
|
break;
|
||||||
|
|
@ -853,8 +853,7 @@ void handleInvoiceAction(BuildContext? context, List<BaseEntity?> invoices,
|
||||||
final data = json.encode(
|
final data = json.encode(
|
||||||
{'ids': invoiceIds, 'action': EntityAction.bulkPrint.toApiParam()});
|
{'ids': invoiceIds, 'action': EntityAction.bulkPrint.toApiParam()});
|
||||||
final http.Response? response = await (WebClient()
|
final http.Response? response = await (WebClient()
|
||||||
.post(url, state.credentials.token, data: data, rawResponse: true)
|
.post(url, state.credentials.token, data: data, rawResponse: true));
|
||||||
as FutureOr<Response?>);
|
|
||||||
store.dispatch(StopSaving());
|
store.dispatch(StopSaving());
|
||||||
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -620,8 +620,8 @@ void handlePurchaseOrderAction(BuildContext? context,
|
||||||
final invitation = purchaseOrder!.invitations.first;
|
final invitation = purchaseOrder!.invitations.first;
|
||||||
final url = invitation.downloadLink;
|
final url = invitation.downloadLink;
|
||||||
store.dispatch(StartSaving());
|
store.dispatch(StartSaving());
|
||||||
final http.Response? response = await (WebClient()
|
final http.Response? response =
|
||||||
.get(url, '', rawResponse: true) as FutureOr<Response?>);
|
await (WebClient().get(url, '', rawResponse: true));
|
||||||
store.dispatch(StopSaving());
|
store.dispatch(StopSaving());
|
||||||
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
||||||
break;
|
break;
|
||||||
|
|
@ -633,8 +633,7 @@ void handlePurchaseOrderAction(BuildContext? context,
|
||||||
'action': EntityAction.bulkPrint.toApiParam()
|
'action': EntityAction.bulkPrint.toApiParam()
|
||||||
});
|
});
|
||||||
final http.Response? response = await (WebClient()
|
final http.Response? response = await (WebClient()
|
||||||
.post(url, state.credentials.token, data: data, rawResponse: true)
|
.post(url, state.credentials.token, data: data, rawResponse: true));
|
||||||
as FutureOr<Response?>);
|
|
||||||
store.dispatch(StopSaving());
|
store.dispatch(StopSaving());
|
||||||
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -741,8 +741,8 @@ Future handleQuoteAction(BuildContext context, List<BaseEntity?> quotes,
|
||||||
final invitation = quote!.invitations.first;
|
final invitation = quote!.invitations.first;
|
||||||
final url = invitation.downloadLink;
|
final url = invitation.downloadLink;
|
||||||
store.dispatch(StartSaving());
|
store.dispatch(StartSaving());
|
||||||
final http.Response? response = await (WebClient()
|
final http.Response? response =
|
||||||
.get(url, '', rawResponse: true) as FutureOr<Response?>);
|
await (WebClient().get(url, '', rawResponse: true));
|
||||||
store.dispatch(StopSaving());
|
store.dispatch(StopSaving());
|
||||||
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
||||||
break;
|
break;
|
||||||
|
|
@ -752,8 +752,7 @@ Future handleQuoteAction(BuildContext context, List<BaseEntity?> quotes,
|
||||||
final data = json.encode(
|
final data = json.encode(
|
||||||
{'ids': quoteIds, 'action': EntityAction.bulkPrint.toApiParam()});
|
{'ids': quoteIds, 'action': EntityAction.bulkPrint.toApiParam()});
|
||||||
final http.Response? response = await (WebClient()
|
final http.Response? response = await (WebClient()
|
||||||
.post(url, state.credentials.token, data: data, rawResponse: true)
|
.post(url, state.credentials.token, data: data, rawResponse: true));
|
||||||
as FutureOr<Response?>);
|
|
||||||
store.dispatch(StopSaving());
|
store.dispatch(StopSaving());
|
||||||
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ class _ClientPdfViewState extends State<ClientPdfView> {
|
||||||
state.credentials.token,
|
state.credentials.token,
|
||||||
data: data,
|
data: data,
|
||||||
rawResponse: true,
|
rawResponse: true,
|
||||||
) as FutureOr<Response?>);
|
));
|
||||||
|
|
||||||
if (response!.statusCode >= 400) {
|
if (response!.statusCode >= 400) {
|
||||||
String errorMessage =
|
String errorMessage =
|
||||||
|
|
@ -356,8 +356,12 @@ class _ClientPdfViewState extends State<ClientPdfView> {
|
||||||
} else {
|
} else {
|
||||||
final directory = await (isDesktopOS()
|
final directory = await (isDesktopOS()
|
||||||
? getDownloadsDirectory()
|
? getDownloadsDirectory()
|
||||||
as FutureOr<file.Directory>
|
|
||||||
: getApplicationDocumentsDirectory());
|
: getApplicationDocumentsDirectory());
|
||||||
|
|
||||||
|
if (directory == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String filePath =
|
String filePath =
|
||||||
'${directory.path}${file.Platform.pathSeparator}$fileName';
|
'${directory.path}${file.Platform.pathSeparator}$fileName';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -654,6 +654,7 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
||||||
final options = productIds
|
final options = productIds
|
||||||
.map((productId) =>
|
.map((productId) =>
|
||||||
productState.map[productId])
|
productState.map[productId])
|
||||||
|
.whereType<ProductEntity>()
|
||||||
.where((product) {
|
.where((product) {
|
||||||
final filter =
|
final filter =
|
||||||
textEditingValue.text.toLowerCase();
|
textEditingValue.text.toLowerCase();
|
||||||
|
|
@ -678,10 +679,8 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
||||||
return <ProductEntity>[];
|
return <ProductEntity>[];
|
||||||
}
|
}
|
||||||
|
|
||||||
return options
|
return options;
|
||||||
as FutureOr<Iterable<ProductEntity>>;
|
},
|
||||||
} as FutureOr<Iterable<ProductEntity>> Function(
|
|
||||||
TextEditingValue),
|
|
||||||
displayStringForOption: (product) =>
|
displayStringForOption: (product) =>
|
||||||
product.productKey,
|
product.productKey,
|
||||||
onSelected: (product) {
|
onSelected: (product) {
|
||||||
|
|
|
||||||
|
|
@ -271,8 +271,12 @@ class _InvoicePdfViewState extends State<InvoicePdfView> {
|
||||||
} else {
|
} else {
|
||||||
final directory = await (isDesktopOS()
|
final directory = await (isDesktopOS()
|
||||||
? getDownloadsDirectory()
|
? getDownloadsDirectory()
|
||||||
as FutureOr<file.Directory>
|
|
||||||
: getApplicationDocumentsDirectory());
|
: getApplicationDocumentsDirectory());
|
||||||
|
|
||||||
|
if (directory == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String filePath =
|
String filePath =
|
||||||
'${directory.path}${file.Platform.pathSeparator}$fileName';
|
'${directory.path}${file.Platform.pathSeparator}$fileName';
|
||||||
|
|
||||||
|
|
@ -341,13 +345,12 @@ Future<Response?> _loadPDF(
|
||||||
final url = isDeliveryNote
|
final url = isDeliveryNote
|
||||||
? '/invoices/${invoice.id}/delivery_note'
|
? '/invoices/${invoice.id}/delivery_note'
|
||||||
: '/activities/download_entity/$activityId';
|
: '/activities/download_entity/$activityId';
|
||||||
response = await (WebClient().get('${credential.url}$url', credential.token,
|
response = await (WebClient()
|
||||||
rawResponse: true) as FutureOr<Response?>);
|
.get('${credential.url}$url', credential.token, rawResponse: true));
|
||||||
} else {
|
} else {
|
||||||
final invitation = invoice.invitations.first;
|
final invitation = invoice.invitations.first;
|
||||||
final url = invitation.downloadLink;
|
final url = invitation.downloadLink;
|
||||||
response = await (WebClient().get(url, '', rawResponse: true)
|
response = await (WebClient().get(url, '', rawResponse: true));
|
||||||
as FutureOr<Response?>);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response!.statusCode >= 400) {
|
if (response!.statusCode >= 400) {
|
||||||
|
|
|
||||||
|
|
@ -1227,11 +1227,12 @@ class ReportResult {
|
||||||
.trim()
|
.trim()
|
||||||
.isNotEmpty)
|
.isNotEmpty)
|
||||||
.map((row) => row[index].renderText(context, column))
|
.map((row) => row[index].renderText(context, column))
|
||||||
|
.whereType<String>()
|
||||||
.toSet()
|
.toSet()
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
return options as FutureOr<Iterable<String>>;
|
return options;
|
||||||
} as FutureOr<Iterable<String>> Function(TextEditingValue),
|
},
|
||||||
onSelected: (value) {
|
onSelected: (value) {
|
||||||
final textEditingController = textEditingControllers[column]!;
|
final textEditingController = textEditingControllers[column]!;
|
||||||
textEditingController.text = value;
|
textEditingController.text = value;
|
||||||
|
|
|
||||||
|
|
@ -513,8 +513,13 @@ class ReportsScreenVM {
|
||||||
WebUtils.downloadTextFile(filename, csvData);
|
WebUtils.downloadTextFile(filename, csvData);
|
||||||
} else {
|
} else {
|
||||||
final directory = await (isDesktopOS()
|
final directory = await (isDesktopOS()
|
||||||
? getDownloadsDirectory() as FutureOr<file.Directory>
|
? getDownloadsDirectory()
|
||||||
: getApplicationDocumentsDirectory());
|
: getApplicationDocumentsDirectory());
|
||||||
|
|
||||||
|
if (directory == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final filePath =
|
final filePath =
|
||||||
directory.path + file.Platform.pathSeparator + filename;
|
directory.path + file.Platform.pathSeparator + filename;
|
||||||
final csvFile = file.File(filePath);
|
final csvFile = file.File(filePath);
|
||||||
|
|
|
||||||
|
|
@ -1311,7 +1311,7 @@ class _PdfPreviewState extends State<_PdfPreview> {
|
||||||
)
|
)
|
||||||
.catchError((dynamic error) {
|
.catchError((dynamic error) {
|
||||||
print('## Error: $error');
|
print('## Error: $error');
|
||||||
}) as FutureOr<Response?>);
|
}));
|
||||||
|
|
||||||
setState(() => isLoading = false);
|
setState(() => isLoading = false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue