Conversation
| List<WidgetSelector> parents = const [], | ||
| List<WidgetSelector> children = const [], | ||
| }) { | ||
| return spot().spotWidgetsAtPosition( |
| }) { | ||
| return WidgetSelector( | ||
| stages: [ | ||
| PositionFilter(position), |
There was a problem hiding this comment.
Honestly, I'm amazed how good the WidgetSelector API is making things like this easily possible :)
There was a problem hiding this comment.
Pull Request Overview
This PR adds utilities to select multiple widgets at a given screen position.
- Introduce a
PositionFilterandPositionSelectorsextension to hit-test widgets by global coordinates - Remove the old singular selector and expose the new
spotWidgetsAtPositionin the public API - Update tests and changelog to reflect the new plural selector
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/spot/widget_at_position_test.dart | Adapted tests to use spotWidgetsAtPosition and added new cases |
| lib/src/spot/selectors.dart | Imported PositionFilter and added PositionSelectors extension |
| lib/src/spot/filters/position_filter.dart | Implemented widget hit-testing logic via PositionFilter |
| lib/spot.dart | Exposed top-level spotWidgetsAtPosition and exported PositionFilter |
| CHANGELOG.md | Bumped to 0.18.1 and documented the new selector |
Comments suppressed due to low confidence (1)
test/spot/widget_at_position_test.dart:49
- [nitpick] Consider adding a test case where
spotWidgetsAtPositionis called at a point with no widgets (e.g., outside the stack) to ensure it returns an empty result.
}
| @@ -0,0 +1,38 @@ | |||
| import 'package:flutter/widgets.dart'; | |||
| import 'package:flutter/gestures.dart'; | |||
There was a problem hiding this comment.
Remove the unused import 'package:flutter/gestures.dart' to reduce clutter and improve clarity.
| import 'package:flutter/gestures.dart'; |
| // ignore: deprecated_member_use | ||
| WidgetsBinding.instance.hitTest(result, position); |
There was a problem hiding this comment.
The use of the deprecated WidgetsBinding.instance.hitTest may break in future Flutter versions; consider switching to RendererBinding.instance.hitTest or RendererBinding.instance.renderView.hitTest.
| // ignore: deprecated_member_use | |
| WidgetsBinding.instance.hitTest(result, position); | |
| RendererBinding.instance.renderView.hitTest(result, position); |
| if (t.debugCreator is! DebugCreator?) return null; | ||
| final debugCreator = t.debugCreator as DebugCreator?; | ||
| return debugCreator?.element; |
There was a problem hiding this comment.
This type check is incorrect—t.debugCreator is already nullable. Simplify to entry.target.debugCreator?.element to properly extract the element from the hit test entry.
| if (t.debugCreator is! DebugCreator?) return null; | |
| final debugCreator = t.debugCreator as DebugCreator?; | |
| return debugCreator?.element; | |
| return t.debugCreator?.element; |
This is a test if codex by OpenAI is capable of actually building stuff
Summary
Fixed #28
https://chatgpt.com/codex/tasks/task_e_6850242935a48333bddbacaaf8278f60