isRedundantLeafUnderKeyedIconShell function

bool isRedundantLeafUnderKeyedIconShell(
  1. Element element
)

Leaf text/media under a keyed compact icon shell (back button, etc.).

The keyed host already observes as icon — keeping the leaf duplicates the row (and overlays) with the same id.

Implementation

bool isRedundantLeafUnderKeyedIconShell(Element element) {
  Element? keyed;
  element.visitAncestorElements((ancestor) {
    if (hasCompactValueKey(ancestor) ||
        readOwnedWidgetLocatorId(ancestor) != null) {
      keyed = ancestor;
      return false;
    }
    return true;
  });
  if (keyed == null) return false;

  final hostBounds = boundsFor(keyed!);
  if (hostBounds != null &&
      (_looksLikeCardHitTarget(hostBounds) ||
          _looksLikeListRowHitTarget(hostBounds))) {
    return false;
  }
  if (_looksLikeCompactIconHitTarget(keyed!)) return true;
  if (hostBounds != null && hostBounds.width <= 72 && hostBounds.height <= 72) {
    return true;
  }
  // KeyedSubtree → IconButton / compact InkWell.
  final primary = findPrimaryControlDescendant(keyed!);
  if (primary == null) return false;
  if (_isIconButtonWidget(primary.widget)) return true;
  if (_isGenericTapTarget(primary.widget) &&
      _looksLikeCompactIconHitTarget(primary)) {
    return true;
  }
  return false;
}