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