@@ -577,7 +577,7 @@ class InspectorTreeController extends DisposableController
577
577
578
578
void scrollToRect (Rect targetRect) {
579
579
for (final client in _clients) {
580
- client.scrollToRect (targetRect);
580
+ client.waitForClientsThenScrollToRect (targetRect);
581
581
}
582
582
}
583
583
@@ -853,6 +853,8 @@ extension RemoteDiagnosticsNodeExtension on RemoteDiagnosticsNode {
853
853
abstract class InspectorControllerClient {
854
854
void scrollToRect (Rect rect);
855
855
856
+ void waitForClientsThenScrollToRect (Rect rect, {int retries});
857
+
856
858
void requestFocus ();
857
859
}
858
860
@@ -916,6 +918,10 @@ class _InspectorTreeState extends State<InspectorTree>
916
918
readyWhen: (triggerValue) => ! triggerValue,
917
919
);
918
920
}
921
+
922
+ WidgetsBinding .instance.addPostFrameCallback ((_) {
923
+ controller.animateTo (controller.selectedNode.value);
924
+ });
919
925
}
920
926
921
927
@override
@@ -964,6 +970,19 @@ class _InspectorTreeState extends State<InspectorTree>
964
970
// );
965
971
// }
966
972
973
+ @override
974
+ Future <void > waitForClientsThenScrollToRect (
975
+ Rect rect, {
976
+ int retries = 5 ,
977
+ }) async {
978
+ if (_scrollControllerY.hasClients || _scrollControllerX.hasClients) {
979
+ return scrollToRect (rect);
980
+ }
981
+ if (retries == 0 ) return ;
982
+ await Future .delayed (const Duration (milliseconds: 20 ));
983
+ return waitForClientsThenScrollToRect (rect, retries: retries - 1 );
984
+ }
985
+
967
986
@override
968
987
Future <void > scrollToRect (Rect rect) async {
969
988
if (rect == _currentAnimateTarget) {
0 commit comments