Skip to content

Commit

Permalink
Layer ... was previously used as oldLayer assertion error in debug …
Browse files Browse the repository at this point in the history
…mode, and page being blank in release mode, caused by LeaderLayer addToScene bug (flutter#113998)
  • Loading branch information
fzyzcjy committed Nov 1, 2022
1 parent eadda3c commit fb9065f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/flutter/lib/src/rendering/layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2503,6 +2503,8 @@ class LeaderLayer extends ContainerLayer {
Matrix4.translationValues(offset.dx, offset.dy, 0.0).storage,
oldLayer: _engineLayer as ui.TransformEngineLayer?,
);
} else {
engineLayer = null;
}
addChildrenToScene(builder);
if (offset != Offset.zero) {
Expand Down
29 changes: 29 additions & 0 deletions packages/flutter/test/widgets/composited_transform_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,35 @@ void main() {
expect(box.localToGlobal(Offset.zero), const Offset(118.0, 451.0));
});

testWidgets('LeaderLayer should not cause error', (WidgetTester tester) async {
final LayerLink link = LayerLink();

Widget buildWidget({
required double paddingLeft,
Color siblingColor = const Color(0xff000000),
}) {
return Directionality(
textDirection: TextDirection.ltr,
child: Stack(
children: <Widget>[
Padding(
padding: EdgeInsets.only(left: paddingLeft),
child: CompositedTransformTarget(
link: link,
child: RepaintBoundary(child: ClipRect(child: Container(color: const Color(0x00ff0000)))),
),
),
Positioned.fill(child: RepaintBoundary(child: ColoredBox(color: siblingColor))),
],
),
);
}

await tester.pumpWidget(buildWidget(paddingLeft: 10));
await tester.pumpWidget(buildWidget(paddingLeft: 0));
await tester.pumpWidget(buildWidget(paddingLeft: 0, siblingColor: const Color(0x0000ff00)));
});

group('Composited transforms - only offsets', () {
final GlobalKey key = GlobalKey();

Expand Down

0 comments on commit fb9065f

Please sign in to comment.