mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Make the inspector handle widgets with non-invertible transforms gracefully. (#15761)
This commit is contained in:
parent
19ef85bf6c
commit
4e5acef664
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user