Layer ... was previously used as oldLayer assertion error in debug mode, and page being blank in release mode, caused by LeaderLayer addToScene bug (#113998)

This commit is contained in:
fzyzcjy 2022-11-02 06:17:08 +08:00 committed by GitHub
parent eadda3c393
commit fb9065fe00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -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) {

View File

@ -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();