execute method
Implementation
@override
Future<Map<String, dynamic>> execute(List arguments, elementMap) async {
// Validate input arguments
if (arguments.length < 3) {
throw Exception('Insufficient arguments provided!');
}
// Retrieve the element
RxElement? element = elementMap[arguments[0]];
if (element == null) {
throw Exception('Element not found!');
}
// Retrieve coordinates and action
var left = element.properties['ScreenX']?.toDouble();
var top = element.properties['ScreenY']?.toDouble();
var width = element.properties['Width']?.toDouble();
var height = element.properties['Height']?.toDouble();
double centerX = left + width / 2;
double centerY = top + height / 2;
FlutterView view = WidgetsBinding.instance.platformDispatcher.views.first;
var devicePixelRatio = view.devicePixelRatio;
double startX = centerX / devicePixelRatio;
double startY = centerY / devicePixelRatio;
String action = arguments[2];
int stepsToMove = action.toLowerCase() == touchMoveTag ? 2 : 1;
double endX = startX + 500;
double endY = startY;
// Perform the motion event
pointerDown(startX, startY);
await pointerMove(startX, startY, endX, endY, stepsToMove, const Duration(milliseconds: duration));
pointerUp(endX, endY);
return {'success': true, 'x': startX, 'y': startY, 'action': action};
}