From e916ea399b3f98a2f6826008673f0ae1c0a74805 Mon Sep 17 00:00:00 2001 From: Frank Merkel <138444693+frankmer@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:17:58 +0200 Subject: [PATCH] improved logging (#396) --- lib/utils/logger.dart | 2 +- .../qr_scanner_view_widgets/qr_scanner_widget.dart | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/utils/logger.dart b/lib/utils/logger.dart index 53a40e504..0dd1e2d1c 100644 --- a/lib/utils/logger.dart +++ b/lib/utils/logger.dart @@ -266,7 +266,7 @@ Device Parameters $deviceInfo"""; error( 'Uncaught Error: ${isolateError.first.toString()}', error: isolateError.first.toString(), - stackTrace: isolateError.last.toString(), + stackTrace: isolateError.length >= 2 && isolateError[1] != null && isolateError[1].toString() != '' ? isolateError[1] : StackTrace.current, ); }).sendPort, ); diff --git a/lib/views/qr_scanner_view/qr_scanner_view_widgets/qr_scanner_widget.dart b/lib/views/qr_scanner_view/qr_scanner_view_widgets/qr_scanner_widget.dart index 587a79a62..d26467352 100644 --- a/lib/views/qr_scanner_view/qr_scanner_view_widgets/qr_scanner_widget.dart +++ b/lib/views/qr_scanner_view/qr_scanner_view_widgets/qr_scanner_widget.dart @@ -25,11 +25,11 @@ Result? _decodeQRCode(BinaryBitmap bitmap) { /// Args: [SendPort] sendPort, [CameraImage] cameraImage, [int] rotation, [double] borderPaddingPercent void _scanQrCodeIsolate(List args) { final SendPort sendPort = args[0] as SendPort; - final CameraImage cameraImage = args[1] as CameraImage; - final int rotation = args[2] as int; - final double borderPaddingPercent = args[3] as double; - try { + final CameraImage cameraImage = args[1] as CameraImage; + final int rotation = args[2] as int; + final double borderPaddingPercent = args[3] as double; + final imgSize = min(cameraImage.width, cameraImage.height); final cropPadding = (imgSize * borderPaddingPercent / 100).round(); final cropHorizontal = (cameraImage.width - imgSize + cropPadding) ~/ 2; @@ -50,14 +50,9 @@ void _scanQrCodeIsolate(List args) { ); var bitmap = BinaryBitmap(GlobalHistogramBinarizer(source)); Result? result = _decodeQRCode(bitmap); - if (result == null) { - sendPort.send(null); - return; - } sendPort.send(result); return; } catch (e) { - Logger.error('Error while scanning QR code: $e, name: _QRScannerWidgetState#_scanQrCode'); sendPort.send(e); return; }