scrapeAllElements method

void scrapeAllElements(
  1. ElementData activeElementData,
  2. Element element,
  3. bool isSensitive,
  4. Map<Type, bool> sensitiveWidgetsTypes,
)

Implementation

void scrapeAllElements(
  ElementData activeElementData,
  Element element,
  bool isSensitive,
  Map<Type, bool> sensitiveWidgetsTypes,
) {
  //todo create option for people using something else than [RenderBox]     //if (renderObject is RenderBox) {
  ElementData? newElementData;
  bool elementIsSensitive = isSensitive;

  // element has its own render object to create skeleton from
  if (element is RenderObjectElement) {
    //do not merge ifs. [element.renderObject] getter is not instant
    final elementDataNullable = describeRenderObject(activeElementData, element, isSensitive, () {
      elementIsSensitive = false;
    });

    if (elementDataNullable.doNotRecordWireframeChildren) {
      return;
    }
    newElementData = elementDataNullable.elementData;
  } else if (element.widget is SmartlookTrackingWidget) {
    final trackingWidget = element.widget as SmartlookTrackingWidget;

    if (trackingWidget.doNotRecordWireframe) {
      final ElementData? elementData = getFirstElementDataFromElement(
        element,
        "doNotRecordWireframe",
        isSensitive: true,
      );

      if (elementData != null) {
        activeElementData.addChildren(elementData);
      }

      return;
    }

    if (trackingWidget.isSensitive) {
      //todo solve case when there is no render object below
      elementIsSensitive = true;
    }
  } else if (sensitiveWidgetsTypes[element.widget.runtimeType] == true) {
    elementIsSensitive = true;
  }

  element.debugVisitOnstageChildren((thisElement) {
    scrapeAllElements(
      newElementData ?? activeElementData,
      thisElement,
      elementIsSensitive,
      sensitiveWidgetsTypes,
    );
  });
}