nativeTap function

Future<NativeTapResult> nativeTap(
  1. NativeTapInput input
)

Taps native (non-Flutter) UI elements using platform-specific tools.

On Android this goes through adb shell input tap, which reaches any on-screen UI regardless of process.

On iOS simulator there is no dependency-free mechanism that crosses the SpringBoard process boundary, so this delegates to the in-process UIApplication.sendEvent() path (the same one fdb tap --at uses). That path reaches UIAlertController and other in-app native overlays but cannot reach SpringBoard-level system dialogs ("Allow location access?", "Open in Test App?", etc.). The CLI adapter emits a WARNING so callers know the limitation.

Never throws; all error conditions are represented as sealed result cases.

Implementation

Future<NativeTapResult> nativeTap(NativeTapInput input) async {
  final platformInfo = readPlatformInfo();
  if (platformInfo == null) return const NativeTapNoSession();

  final platform = platformInfo.platform;
  final isEmulator = platformInfo.emulator;

  if (platform.startsWith('android')) {
    return _tapAndroid(input: input);
  }

  if (platform.startsWith('ios') && isEmulator) {
    return _tapIosSimulator(input: input);
  }

  if (platform.startsWith('ios') && !isEmulator) {
    return NativeTapPhysicalIosUnsupported(x: input.x, y: input.y);
  }

  if (platform.startsWith('darwin')) {
    return NativeTapMacosUnsupported(x: input.x, y: input.y);
  }

  return NativeTapPlatformUnsupported(platform);
}