Open Murmurl912 opened 5 months ago
Here is crash log:
ERROR 'package:screenshot/screenshot.dart': Failed assertion: line 155 pos 12: 'logicalSize.aspectRatio.toStringAsPrecision(5) == ERROR imageSize.aspectRatio ERROR .toStringAsPrecision(5)': is not true. ERROR #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61) ERROR #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5) ERROR #2 ScreenshotController.widgetToUiImage (package:screenshot/screenshot.dart:155:12) ERROR #3 ScreenshotController.captureFromWidget (package:screenshot/screenshot.dart:102:28)
I am using screenshot 2.3.0. The code used to capture screenshot is:
final capture = await screenshotController.captureFromWidget( SomWidget(), context: context, pixelRatio: 1080 / 390.0 / 2);
The assert is thrown in line 153:
final RenderRepaintBoundary repaintBoundary = RenderRepaintBoundary(); final platformDispatcher = WidgetsBinding.instance.platformDispatcher; final fallBackView = platformDispatcher.views.first; final view = context == null ? fallBackView : View.maybeOf(context) ?? fallBackView; Size logicalSize = targetSize ?? view.physicalSize / view.devicePixelRatio; // Adapted Size imageSize = targetSize ?? view.physicalSize; // Adapted assert(logicalSize.aspectRatio.toStringAsPrecision(5) == imageSize.aspectRatio .toStringAsPrecision(5)); // Adapted (toPrecision was not available)
logicalSize = Size(417.5, 975.2) imageSize = Size(1096.0, 2560.0) view.physicalSize = Size(1096.0, 2560.0) view.devicePixelRatio = 2.625 logicalSize.aspectRatio = 0.42812500000000003 imageSize.aspectRatio = 0.428125 imageSize.aspectRatio.toStringAsPrecision(5) = 0.42812 logicalSize.aspectRatio.toStringAsPrecision(5) = 0.42813
Why the assertion in line 153 is needed, a small rounding error could fail it:
assert(logicalSize.aspectRatio.toStringAsPrecision(5) == imageSize.aspectRatio .toStringAsPrecision(5)); // Adapted (toPrecision was not available)
Here is crash log:
ERROR 'package:screenshot/screenshot.dart': Failed assertion: line 155 pos 12: 'logicalSize.aspectRatio.toStringAsPrecision(5) == ERROR imageSize.aspectRatio ERROR .toStringAsPrecision(5)': is not true. ERROR #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61) ERROR #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5) ERROR #2 ScreenshotController.widgetToUiImage (package:screenshot/screenshot.dart:155:12) ERROR #3 ScreenshotController.captureFromWidget (package:screenshot/screenshot.dart:102:28)
I am using screenshot 2.3.0. The code used to capture screenshot is:
The assert is thrown in line 153:
Why the assertion in line 153 is needed, a small rounding error could fail it: