rectForVisuallyActionable method

Rect? rectForVisuallyActionable(
  1. Finder finder, {
  2. bool requireHitTestable = false,
})

Bounds for firstVisuallyActionableElement, or null when none qualify.

Implementation

Rect? rectForVisuallyActionable(
  Finder finder, {
  bool requireHitTestable = false,
}) {
  final element = firstVisuallyActionableElement(
    finder,
    requireHitTestable: requireHitTestable,
  );
  if (element == null) return null;
  final renderObject = element.renderObject;
  if (renderObject is! RenderBox ||
      !renderObject.hasSize ||
      renderObject.size.isEmpty) {
    return null;
  }
  final topLeft = renderObject.localToGlobal(Offset.zero);
  final rect = topLeft & renderObject.size;
  if (!rect.isFinite || rect.isEmpty) return null;
  return rect;
}