Make the inspector handle widgets with non-invertible transforms gracefully. (#15761)
This commit is contained in:
@@ -564,7 +564,14 @@ class _WidgetInspectorState extends State<WidgetInspector>
|
|||||||
Matrix4 transform,
|
Matrix4 transform,
|
||||||
) {
|
) {
|
||||||
bool hit = false;
|
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 Offset localPosition = MatrixUtils.transformPoint(inverse, position);
|
||||||
|
|
||||||
final List<DiagnosticsNode> children = object.debugDescribeChildren();
|
final List<DiagnosticsNode> children = object.debugDescribeChildren();
|
||||||
|
|||||||
@@ -117,6 +117,31 @@ void main() {
|
|||||||
expect(paragraphText(getInspectorState().selection.current), equals('BOTTOM'));
|
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 {
|
testWidgets('WidgetInspector scroll test', (WidgetTester tester) async {
|
||||||
final Key childKey = new UniqueKey();
|
final Key childKey = new UniqueKey();
|
||||||
final GlobalKey selectButtonKey = new GlobalKey();
|
final GlobalKey selectButtonKey = new GlobalKey();
|
||||||
|
|||||||
Reference in New Issue
Block a user