ClickInfo.from constructor

ClickInfo.from({
  1. required Element gestureElement,
  2. required PointerDownEvent event,
  3. required Element pageElement,
  4. required PageInfo pageInfo,
})

Implementation

factory ClickInfo.from({
  required Element gestureElement,
  required PointerDownEvent event,
  required Element pageElement,
  required PageInfo pageInfo,
}) {
  ClickInfo clickInfo = ClickInfo._(pageInfo);
  clickInfo._touchX = event.position.dx.round();
  clickInfo._touchY = event.position.dy.round();

  XPath xpath = XPath.createBy(element: gestureElement, pageElement: pageElement);
  Element element = xpath.targetElement;
  clickInfo._elementType = element.widget.runtimeType.toString();
  clickInfo._elementWidth = element.size?.width.round() ?? 0;
  clickInfo._elementHeight = element.size?.height.round() ?? 0;
  clickInfo._elementPath = xpath.toString();
  clickInfo._texts = ElementUtil.findTexts(element);
  // print(clickInfo._elementPath);

  Key? key = element.widget.key;
  clickInfo._elementManualKey = key?.toString() ?? '';
  clickInfo._ignore = AutoTrackConfigManager.instance.isIgnoreElement(key);
  if (key is RangersApplogElementKey && !clickInfo._ignore) {
    clickInfo._ignore = key.ignore;
  }

  return clickInfo;
}