Skip to content

Commit 186659d

Browse files
authored
Show width and height in inspector overlay (#140709)
![](https://media.giphy.com/media/SX71qs3TDxVkvbLJ4o/giphy-downsized.gif) Fixes flutter/devtools#6871 Add the width and height to the inspector overlay. 1 decimal precision is used since that matches the way Devtools displays the values. ## Examples <img width="442" alt="Screenshot 2023-12-28 at 2 39 49�PM" src="https://github.com/flutter/flutter/assets/1386322/2de40092-de15-4ada-a954-e911e6bef217"> <img width="645" alt="Screenshot 2023-12-28 at 2 39 42�PM" src="https://github.com/flutter/flutter/assets/1386322/8f53dad5-1aba-43d9-9419-ca93cd894624"> <img width="149" alt="Screenshot 2023-12-28 at 2 39 37�PM" src="https://github.com/flutter/flutter/assets/1386322/bbed74b7-c962-4c20-80d8-48e5eaa14de6">
1 parent 396a530 commit 186659d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/flutter/lib/src/widgets/widget_inspector.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3188,11 +3188,15 @@ class _InspectorOverlayLayer extends Layer {
31883188
}
31893189
candidates.add(_TransformedRect(candidate, rootRenderObject));
31903190
}
3191+
final _TransformedRect selectedRect = _TransformedRect(selected, rootRenderObject);
3192+
final String widgetName = selection.currentElement!.toStringShort();
3193+
final String width = selectedRect.rect.width.toStringAsFixed(1);
3194+
final String height = selectedRect.rect.height.toStringAsFixed(1);
31913195

31923196
final _InspectorOverlayRenderState state = _InspectorOverlayRenderState(
31933197
overlayRect: overlayRect,
3194-
selected: _TransformedRect(selected, rootRenderObject),
3195-
tooltip: selection.currentElement!.toStringShort(),
3198+
selected: selectedRect,
3199+
tooltip: '$widgetName ($width x $height)',
31963200
textDirection: TextDirection.ltr,
31973201
candidates: candidates,
31983202
);

0 commit comments

Comments
 (0)