Repository: flutter
Issue: onLongPressCancel is not called, when child GestureDetector listens for horizontal drag
Labels: framework,f: gestures,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.22,found in release: 3.24

### Steps to reproduce

1. Run the code sample
2. Drag the screen horizontally

### Expected results

Prints:
```
flutter: onLongPressDown
flutter: onLongPressCancel
flutter: onHorizontalDragStart
flutter: onHorizontalDragEnd
```

### Actual results

Prints:
```
flutter: onLongPressDown
flutter: onHorizontalDragStart
flutter: onHorizontalDragEnd
```

### Workaround
A workaround is to use `onPanCancel` in the outer GestureDetector as a replacement for `oneLongPressCancel`. A similar workaround got proposed in a similar - already closed - issue: https://github.com/flutter/flutter/issues/25610#issuecomment-458054096.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:long_press_cancel_bug/hit_response.dart';
import 'package:long_press_cancel_bug/slide_to_action.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: GestureDetector(
          onLongPressDown: (_) {
            print('onLongPressDown');
          },
          onLongPressCancel: () {
            print('onLongPressCancel');
          },
          child: GestureDetector(
            onHorizontalDragStart: (_) {
              print('onHorizontalDragStart');
            },
            onHorizontalDragEnd: (_) {
              print('onHorizontalDragEnd');
            },
            child: Container(
              alignment: Alignment.center,
              color: Colors.white,
              child: const Text('Drag me horizontally'),
            ),
          ),
        ),
      ),
    );
  }
}
```

</details>

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[!] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale en-DE)
    • Flutter version 3.22.2 on channel stable at /Users/tobias/dev/tools/flutter
    ! Warning: `flutter` on your path resolves to /Users/tobias/Dev/Tools/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/tobias/dev/tools/flutter. Consider adding /Users/tobias/dev/tools/flutter/bin to the front
      of your path.
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/3.2.2/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/tobias/dev/tools/flutter. Consider adding /Users/tobias/dev/tools/flutter/bin to the
      front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (5 weeks ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/tobias/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/tobias/Library/Android/sdk
    • Java binary at: /Users/tobias/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3)
    • Android Studio at /Users/tobias/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.1.3)
    • IntelliJ at /Users/tobias/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 80.0.2
    • Dart plugin version 241.17890.8

[✓] VS Code (version 1.91.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (4 available)
    • iPhone 15 Pro (mobile)          • 22F4D333-AC4B-4F70-8037-74C00161C2BC • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 14.5 23F79 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 14.5 23F79 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 126.0.6478.127
    ! Error: Browsing on the local area network for iPad von Florian. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
```

</details>