Skip to content

Commit

Permalink
improved logging (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankmer authored Jun 25, 2024
1 parent 1d10ad4 commit e916ea3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/utils/logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit e916ea3

Please sign in to comment.