configureTesterForSize function
Future<void>
configureTesterForSize(
- WidgetTester tester,
- Size canvasSize,
- double devicePixelRatio
Configures the test surface size for golden tests.
Divides by devicePixelRatio to convert physical pixels to logical pixels,
then sets devicePixelRatio to 1.0 so golden images match 1:1 with logical size.
Implementation
Future<void> configureTesterForSize(
WidgetTester tester,
Size canvasSize,
double devicePixelRatio,
) async {
final convertedSize = Size(
canvasSize.width / devicePixelRatio,
canvasSize.height / devicePixelRatio,
);
await tester.binding.setSurfaceSize(convertedSize);
tester.view.physicalSize = convertedSize;
tester.view.devicePixelRatio = 1.0;
}