flutter: is it possible to click at a certain x,y coordinate on the screen?
606
After looking at flutter_test's source code, Here is what I came up with:
void tap(Offset pos){
final result = HitTestResult();
WidgetsBinding.instance.hitTest(result, pos);
result.path.forEach((element) {
element.target.handleEvent(
PointerDownEvent(
localPosition: pos,
kind: PointerDeviceKind.touch),
element,
);
element.target.handleEvent(
PointerUpEvent(
localPosition: pos,
kind: PointerDeviceKind.touch),
element,
);
});
}
![Arham Aalam Ansari](https://i.stack.imgur.com/EKTq3.png?s=256&g=1)
Author by
Arham Aalam Ansari
Combining technologies to build something innovative with the knowledge of Backend and computer vision skill set. Working on AI based risk mitigation tools | Building a Computer Vision based game "Astral Space" (coming soon on steam).
Updated on December 23, 2022Comments
-
Arham Aalam Ansari over 1 year
I'm trying to find a way where I can automatically click on any (x, y) coordinate of the screen without user involvement. basically I need to develop this functionality for android in flutter. we may take inspiration from ADB, like this command allow us to tap on x,y coordinates.
adb shell input tap x y
-
Jigar Patel almost 4 yearsthis answer might help - stackoverflow.com/a/54641119/13840864
-