Skip to content

Implement spotWidgetAtPosition utilities#118

Open
passsy wants to merge 1 commit intomainfrom
codex/fix-issue-#28
Open

Implement spotWidgetAtPosition utilities#118
passsy wants to merge 1 commit intomainfrom
codex/fix-issue-#28

Conversation

@passsy
Copy link
Owner

@passsy passsy commented Jun 16, 2025

This is a test if codex by OpenAI is capable of actually building stuff

Summary

  • add position filter to evaluate hit tests during snapshot
  • remove singular widget-at-position selector from the public API
  • expose new filter in the public exports
  • adjust changelog and tests for plural selector

Fixed #28


https://chatgpt.com/codex/tasks/task_e_6850242935a48333bddbacaaf8278f60

List<WidgetSelector> parents = const [],
List<WidgetSelector> children = const [],
}) {
return spot().spotWidgetsAtPosition(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use _global. not spot()

@passsy passsy requested a review from Copilot June 16, 2025 15:05
}) {
return WidgetSelector(
stages: [
PositionFilter(position),
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I'm amazed how good the WidgetSelector API is making things like this easily possible :)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds utilities to select multiple widgets at a given screen position.

  • Introduce a PositionFilter and PositionSelectors extension to hit-test widgets by global coordinates
  • Remove the old singular selector and expose the new spotWidgetsAtPosition in 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 spotWidgetsAtPosition is 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';
Copy link

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unused import 'package:flutter/gestures.dart' to reduce clutter and improve clarity.

Suggested change
import 'package:flutter/gestures.dart';

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +18
// ignore: deprecated_member_use
WidgetsBinding.instance.hitTest(result, position);
Copy link

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// ignore: deprecated_member_use
WidgetsBinding.instance.hitTest(result, position);
RendererBinding.instance.renderView.hitTest(result, position);

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +25
if (t.debugCreator is! DebugCreator?) return null;
final debugCreator = t.debugCreator as DebugCreator?;
return debugCreator?.element;
Copy link

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if (t.debugCreator is! DebugCreator?) return null;
final debugCreator = t.debugCreator as DebugCreator?;
return debugCreator?.element;
return t.debugCreator?.element;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spotWidgetAtPosition

1 participant