Unverified Commit 4e5acef6 authored by Jacob Richman's avatar Jacob Richman Committed by GitHub

Make the inspector handle widgets with non-invertible transforms gracefully. (#15761)

parent 19ef85bf
......@@ -564,7 +564,14 @@ class _WidgetInspectorState extends State<WidgetInspector>
Matrix4 transform,
) {
bool hit = false;
final Matrix4 inverse = new Matrix4.inverted(transform);
Matrix4 inverse;
try {
inverse = new Matrix4.inverted(transform);
} on ArgumentError {
// We cannot invert the transform. That means the object doesn't appear on
// screen and cannot be hit.
return false;
}
final Offset localPosition = MatrixUtils.transformPoint(inverse, position);
final List<DiagnosticsNode> children = object.debugDescribeChildren();
......
......@@ -117,6 +117,31 @@ void main() {
expect(paragraphText(getInspectorState().selection.current), equals('BOTTOM'));
});
testWidgets('WidgetInspector non-invertible transform regression test', (WidgetTester tester) async {
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new WidgetInspector(
selectButtonBuilder: null,
child: new Transform(
transform: new Matrix4.identity()..scale(0.0),
child: new Stack(
children: const <Widget>[
const Text('a', textDirection: TextDirection.ltr),
const Text('b', textDirection: TextDirection.ltr),
const Text('c', textDirection: TextDirection.ltr),
],
),
),
),
),
);
await tester.tap(find.byType(Transform));
expect(true, isTrue); // Expect that we reach here without crashing.
});
testWidgets('WidgetInspector scroll test', (WidgetTester tester) async {
final Key childKey = new UniqueKey();
final GlobalKey selectButtonKey = new GlobalKey();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment