Skip to content

Commit fb9065f

Browse files
authored
Layer ... was previously used as oldLayer assertion error in debug mode, and page being blank in release mode, caused by LeaderLayer addToScene bug (#113998)
1 parent eadda3c commit fb9065f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

packages/flutter/lib/src/rendering/layer.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2503,6 +2503,8 @@ class LeaderLayer extends ContainerLayer {
25032503
Matrix4.translationValues(offset.dx, offset.dy, 0.0).storage,
25042504
oldLayer: _engineLayer as ui.TransformEngineLayer?,
25052505
);
2506+
} else {
2507+
engineLayer = null;
25062508
}
25072509
addChildrenToScene(builder);
25082510
if (offset != Offset.zero) {

packages/flutter/test/widgets/composited_transform_test.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,35 @@ void main() {
5656
expect(box.localToGlobal(Offset.zero), const Offset(118.0, 451.0));
5757
});
5858

59+
testWidgets('LeaderLayer should not cause error', (WidgetTester tester) async {
60+
final LayerLink link = LayerLink();
61+
62+
Widget buildWidget({
63+
required double paddingLeft,
64+
Color siblingColor = const Color(0xff000000),
65+
}) {
66+
return Directionality(
67+
textDirection: TextDirection.ltr,
68+
child: Stack(
69+
children: <Widget>[
70+
Padding(
71+
padding: EdgeInsets.only(left: paddingLeft),
72+
child: CompositedTransformTarget(
73+
link: link,
74+
child: RepaintBoundary(child: ClipRect(child: Container(color: const Color(0x00ff0000)))),
75+
),
76+
),
77+
Positioned.fill(child: RepaintBoundary(child: ColoredBox(color: siblingColor))),
78+
],
79+
),
80+
);
81+
}
82+
83+
await tester.pumpWidget(buildWidget(paddingLeft: 10));
84+
await tester.pumpWidget(buildWidget(paddingLeft: 0));
85+
await tester.pumpWidget(buildWidget(paddingLeft: 0, siblingColor: const Color(0x0000ff00)));
86+
});
87+
5988
group('Composited transforms - only offsets', () {
6089
final GlobalKey key = GlobalKey();
6190

0 commit comments

Comments
 (0)