Given some (x,y) coordinates, in logical pixels, relative to:
How can I know which widget is in that position?
I think you are after the hitTest
method in RenderBox
class. As per the documentation
Returns true if the given point is contained in this render object or one of its descendants. Adds any render objects that contain the point to the given hit test result.
So you can get the RenderBox instance of the widget from the key context
GlobalKey key = new GlobalKey();
//your stuff
final RenderBox box = key.currentContext.findRenderObject()
// do box.hitTest
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With