getFirstElementDataFromElement method

ElementData? getFirstElementDataFromElement(
  1. Element theElement,
  2. String type, {
  3. bool isSensitive = false,
})

Implementation

ElementData? getFirstElementDataFromElement(
  Element theElement,
  String type, {
  bool isSensitive = false,
}) {
  final renderObject = theElement.renderObject;
  if (renderObject is RenderBox && renderObject.hasSize) {
    final offset = renderObject.localToGlobal(Offset.zero);
    final top = offset.dy;
    final left = offset.dx;

    return ElementData(
      id: theElement.hashCode.toString(),
      type: type,
      rect: Rect.fromLTWH(
        left,
        top,
        renderObject.size.width,
        renderObject.size.height,
      ),
      opacity: 1.0,
      isSensitive: isSensitive,
    );
  }

  return null;
}