Skip to content

Commit c49f5b1

Browse files
committed
Fix autoscale rendering.
1 parent d39cbed commit c49f5b1

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

lib/src/transformers/node_transformers/passive_canvas_transformer.dart

+14-14
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,22 @@ class PassiveCanvasTransformer extends NodeWidgetTransformer<CanvasNode> {
4343
settings: settings)
4444
: null);
4545

46+
if (node.isScrollable) {
47+
body = SingleChildScrollView(
48+
scrollDirection: node.scrollDirection.flutterAxis,
49+
reverse: node.reverse,
50+
primary: node.primary,
51+
physics: node.physics.flutterScrollPhysics,
52+
keyboardDismissBehavior:
53+
node.keyboardDismissBehavior.flutterKeyboardDismissBehavior,
54+
child: body,
55+
);
56+
}
57+
4658
if (node.scaleMode == ScaleMode.autoScale) {
4759
final double screenWidth = MediaQuery.of(context).size.width;
48-
final double screenHeight = MediaQuery.of(context).size.height;
4960
final double canvasWidth = node.outerBoxLocal.width;
61+
final double canvasHeight = node.outerBoxLocal.height;
5062
final double viewRatio = screenWidth / canvasWidth;
5163

5264
// If the width of this canvas is smaller than the viewport's size,
@@ -57,24 +69,12 @@ class PassiveCanvasTransformer extends NodeWidgetTransformer<CanvasNode> {
5769
alignment: Alignment.topCenter,
5870
child: SizedBox(
5971
width: viewRatio < 1 ? canvasWidth : screenWidth,
60-
height: screenHeight,
72+
height: canvasHeight,
6173
child: body,
6274
),
6375
);
6476
}
6577

66-
if (node.isScrollable) {
67-
body = SingleChildScrollView(
68-
scrollDirection: node.scrollDirection.flutterAxis,
69-
reverse: node.reverse,
70-
primary: node.primary,
71-
physics: node.physics.flutterScrollPhysics,
72-
keyboardDismissBehavior:
73-
node.keyboardDismissBehavior.flutterKeyboardDismissBehavior,
74-
child: body,
75-
);
76-
}
77-
7878
final bool needsAScaffold = appBar != null ||
7979
floatingActionButton != null ||
8080
bottomNavigationBar != null;

0 commit comments

Comments
 (0)