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!');
}
String anchor = arguments[1];
// Retrieve the element
RxElement? element = elementMap[arguments[0]];
if (element == null) {
throw Exception('Element not found!');
}
// Retrieve coordinates and action
var left = element.properties[WidgetProperty.screenX.name]?.toDouble();
var top = element.properties[WidgetProperty.screenY.name]?.toDouble();
var width = element.properties[WidgetProperty.width.name]?.toDouble();
var height = element.properties[WidgetProperty.height.name]?.toDouble();
var coordinatesFromAnchor =
resolveCoordinatesFromAnchor(anchor, left, top, width, height);
double startX = coordinatesFromAnchor[0];
double startY = coordinatesFromAnchor[1];
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};
}