diff --git a/packages/flutter/lib/src/widgets/widget_inspector.dart b/packages/flutter/lib/src/widgets/widget_inspector.dart index 5b59d431bb..73de17807f 100644 --- a/packages/flutter/lib/src/widgets/widget_inspector.dart +++ b/packages/flutter/lib/src/widgets/widget_inspector.dart @@ -247,28 +247,34 @@ class _WidgetInspectorState extends State class InspectorSelection { /// Render objects that are candidates to be selected. /// - /// Tools may wish to iterate through the list of candidates + /// Tools may wish to iterate through the list of candidates. List get candidates => _candidates; - + List _candidates = []; set candidates(List value) { _candidates = value; index = 0; } - List _candidates = []; - /// Index within the list of candidates that is currently selected. int index = 0; + /// Set the selection to empty. void clear() { _candidates = []; index = 0; } + /// Selected render object from the [candidates] list. + /// + /// Setting [candidates] or calling [clear] resets the selection. + /// + /// Returns null if the selection is invalid. RenderObject get current { return candidates != null && index < candidates.length ? candidates[index] : null; } + /// Whether the selected render object is attached to the tree or has gone + /// out of scope. bool get active => current != null && current.attached; }