Repository: flutter
Issue: [Linux] GestureDetector detects vertical drag instead of a horizontal drag on touchscreens
Labels: framework,f: gestures,platform-linux,a: desktop,P2,team-linux,triaged-linux

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Steps to Reproduce

<!-- You must include full steps to reproduce so that we can reproduce the problem. -->

1. Run `flutter create bug`.
2. Update main.dart as follows: 
<details>
  <summary>main.dart</summary> 


```dart
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _hCounter = 0;
  int _vCounter = 0;
 
  void _incrementVCounter() {
    print("vertical");
    setState(() {
      _vCounter++;
    });
  }
  void _incrementHCounter() {
    print("horizontal");
    setState(() {
      _hCounter++;
    });
  }

  // Build a GestureDetector on the whole scaffold body and listen for horizontal
  // and vertical drags.
  // Display the number of drags for each type.
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Container(
        width: double.infinity,
        height: double.infinity,
        child: GestureDetector(
          behavior: HitTestBehavior.translucent,
          onHorizontalDragStart: (_) => _incrementHCounter(),
          onVerticalDragStart: (_) => _incrementVCounter(),
          child: Center(
            child: Column(
              children: [
                Container(height: 64),
                Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Text(
                      'You have triggered vertical drag this many times:',
                    ),
                    Text(
                      '$_vCounter',
                      style: Theme.of(context).textTheme.headline4,
                    ),
                  ],
                ),
                Container(height: 64),
                Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Text(
                      'You have triggered horizontal drag this many times:',
                    ),
                    Text(
                      '$_hCounter',
                      style: Theme.of(context).textTheme.headline4,
                    ),
                  ],
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
```

</details>
<!-- include every file that is different from the template app! -->


3. Swipe horizontally

**Expected results:** <!-- what did you want to see? -->

I expected the `onHorizontalDragStart` callback to be called each time I start a horizontal drag.


**Actual results:** <!-- what did you see? -->

90% of the time, the `onVerticalDragStart` callback was called instead.


<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue.
-->

```
 bug flutter run --verbose
[  +51 ms] executing: [/home/joackim/snap/flutter/common/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +23 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] c5a4b4029c0798f37c4a39b479d7cb75daa7b05c
[        ] executing: [/home/joackim/snap/flutter/common/flutter/] git tag --points-at c5a4b4029c0798f37c4a39b479d7cb75daa7b05c
[   +9 ms] Exit code 0 from: git tag --points-at c5a4b4029c0798f37c4a39b479d7cb75daa7b05c
[        ] 2.0.1
[  +27 ms] executing: [/home/joackim/snap/flutter/common/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[   +3 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/beta
[        ] executing: [/home/joackim/snap/flutter/common/flutter/] git ls-remote --get-url origin
[   +4 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +30 ms] executing: [/home/joackim/snap/flutter/common/flutter/] git rev-parse --abbrev-ref HEAD
[   +5 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] beta
[  +34 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +1 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +42 ms] executing: /home/joackim/Android/Sdk/platform-tools/adb devices -l
[  +34 ms] List of devices attached
[   +2 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +56 ms] Skipping pub get: version match.
[  +86 ms] Generating /home/joackim/dev/bug/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
[  +61 ms] Initializing file store
[   +7 ms] Skipping target: gen_localizations
[   +4 ms] complete
[   +3 ms] Launching lib/main.dart on Linux in debug mode...
[   +3 ms] /home/joackim/snap/flutter/common/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev /home/joackim/snap/flutter/common/flutter/bin/cache/artifacts/engine/linux-x64/frontend_server.dart.snapshot --sdk-root /home/joackim/snap/flutter/common/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --incremental --target=flutter
--debugger-module-names --experimental-emit-debug-metadata --output-dill /tmp/flutter_tools.BZQNFR/flutter_tool.RVXLRC/app.dill --packages /home/joackim/dev/bug/.dart_tool/package_config.json -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --filesystem-scheme org-dartlang-root --initialize-from-dill
build/cache.dill.track.dill
[  +15 ms] Building Linux application...
[  +14 ms] <- compile package:bug/main.dart
[   +2 ms] executing: [build/linux/debug/] cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug /home/joackim/dev/bug/linux
[  +38 ms] -- Configuring done
[   +3 ms] -- Generating done
[        ] -- Build files have been written to: /home/joackim/dev/bug/build/linux/debug
[   +3 ms] executing: ninja -C build/linux/debug install
[  +10 ms] ninja: Entering directory `build/linux/debug'
[+2834 ms] [1/5] Generating /home/joackim/dev/bug/linux/flutter/ephemeral/libflutter_linux_gtk.so, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_basic_message_channel.h, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_binary_codec.h, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_binary_messenger.h,
/home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_dart_project.h, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_engine.h, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_json_message_codec.h, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_json_method_codec.h,
/home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_message_codec.h, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_method_call.h, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_method_channel.h, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_method_codec.h,
/home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_method_response.h, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_plugin_registrar.h, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_plugin_registry.h, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_standard_message_codec.h,
/home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_standard_method_codec.h, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_string_codec.h, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_value.h, /home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/fl_view.h,
/home/joackim/dev/bug/linux/flutter/ephemeral/flutter_linux/flutter_linux.h, _phony_
[   +2 ms] [  +55 ms] executing: [/home/joackim/snap/flutter/common/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] [  +25 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] [        ] c5a4b4029c0798f37c4a39b479d7cb75daa7b05c
[        ] [        ] executing: [/home/joackim/snap/flutter/common/flutter/] git tag --points-at c5a4b4029c0798f37c4a39b479d7cb75daa7b05c
[        ] [   +8 ms] Exit code 0 from: git tag --points-at c5a4b4029c0798f37c4a39b479d7cb75daa7b05c
[        ] [        ] 2.0.1
[        ] [  +27 ms] executing: [/home/joackim/snap/flutter/common/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[        ] [   +3 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] [        ] origin/beta
[        ] [        ] executing: [/home/joackim/snap/flutter/common/flutter/] git ls-remote --get-url origin
[        ] [   +2 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] [        ] https://github.com/flutter/flutter.git
[        ] [  +26 ms] executing: [/home/joackim/snap/flutter/common/flutter/] git rev-parse --abbrev-ref HEAD
[        ] [   +3 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] [        ] beta
[        ] [  +34 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] [   +2 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] [  +41 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[        ] [        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] [        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[        ] [  +75 ms] Initializing file store
[        ] [   +5 ms] Done initializing file store
[        ] [  +27 ms] Skipping target: gen_localizations
[        ] [+1305 ms] Skipping target: unpack_linux
[        ] [ +335 ms] Skipping target: kernel_snapshot
[        ] [ +211 ms] Skipping target: debug_bundle_linux_assets
[        ] [        ] Persisting file store
[        ] [   +5 ms] Done persisting file store
[        ] [   +3 ms] build succeeded.
[        ] [   +6 ms] "flutter assemble" took 2,028ms.
[        ] [ +185 ms] ensureAnalyticsSent: 182ms
[        ] [   +2 ms] Running shutdown hooks
[        ] [        ] Shutdown hooks complete
[        ] [        ] exiting with code 0
[ +270 ms] [2/5] Building CXX object CMakeFiles/bug.dir/flutter/generated_plugin_registrant.cc.o
[  +30 ms] [3/5] Building CXX object CMakeFiles/bug.dir/my_application.cc.o
[  +68 ms] [4/5] Linking CXX executable intermediates_do_not_run/bug
[        ] [4/5] Install the project...
[   +8 ms] -- Install configuration: "Debug"
[  +17 ms] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/bug
[        ] -- Set runtime path of "/home/joackim/dev/bug/build/linux/debug/bundle/bug" to "$ORIGIN/lib"
[        ] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/data/icudtl.dat
[        ] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/lib/libflutter_linux_gtk.so
[  +93 ms] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/data/flutter_assets
[        ] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/data/flutter_assets/version.json
[        ] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/data/flutter_assets/packages
[        ] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/data/flutter_assets/packages/cupertino_icons
[        ] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/data/flutter_assets/packages/cupertino_icons/assets
[        ] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/data/flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf
[        ] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/data/flutter_assets/fonts
[        ] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/data/flutter_assets/fonts/MaterialIcons-Regular.otf
[        ] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/data/flutter_assets/AssetManifest.json
[        ] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/data/flutter_assets/NOTICES
[        ] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/data/flutter_assets/FontManifest.json
[        ] -- Installing: /home/joackim/dev/bug/build/linux/debug/bundle/data/flutter_assets/kernel_blob.bin
[  +39 ms] Building Linux application... (completed in 3.4s)
[ +189 ms] Observatory URL on device: http://127.0.0.1:36029/R7WcboEaYq4=/
[   +3 ms] Caching compiled dill
[  +39 ms] Connecting to service protocol: http://127.0.0.1:36029/R7WcboEaYq4=/
[ +106 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at http://127.0.0.1:36029/R7WcboEaYq4=/.
[  +67 ms] DDS is listening at http://127.0.0.1:39985/naykAwWupcI=/.
[  +56 ms] Successfully connected to service protocol: http://127.0.0.1:36029/R7WcboEaYq4=/
[ +679 ms] DevFS: Creating new filesystem on the device (null)
[  +10 ms] DevFS: Created new filesystem on the device (file:///tmp/bugVFHLRZ/bug/)
[   +3 ms] Updating assets
[  +62 ms] Syncing files to device Linux...
[   +1 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[   +1 ms] <- recompile package:bug/main.dart d3540f8d-c322-4c77-8d96-3001871c2775
[        ] <- d3540f8d-c322-4c77-8d96-3001871c2775
[  +73 ms] Updating files.
[        ] DevFS: Sync finished
[   +1 ms] Syncing files to device Linux... (completed in 77ms)
[        ] Synced 0.0MB.
[        ] <- accept
[   +4 ms] Connected to _flutterView/0x27ac570.
[   +1 ms] Flutter run key commands.
[   +1 ms] r Hot reload. 🔥🔥🔥
[   +1 ms] R Hot restart.
[        ] h Repeat this help message.
[        ] d Detach (terminate "flutter run" but leave application running).
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).
[        ] An Observatory debugger and profiler on Linux is available at: http://127.0.0.1:39985/naykAwWupcI=/
[        ] 
           Flutter DevTools, a Flutter debugger and profiler, on Linux is available at: http://127.0.0.1:9101?uri=http%3A%2F%2F127.0.0.1%3A39985%2FnaykAwWupcI%3D%2F
[        ] Running with unsound null safety
[        ] For more information see https://dart.dev/null-safety/unsound-null-safety
[+2832 ms] flutter: vertical
[ +336 ms] flutter: vertical
[ +383 ms] flutter: vertical
[ +383 ms] flutter: vertical
[ +400 ms] flutter: vertical
[ +455 ms] flutter: vertical
[ +412 ms] flutter: vertical
[ +449 ms] flutter: vertical
[ +366 ms] flutter: vertical
[ +416 ms] flutter: vertical
[ +371 ms] flutter: vertical
[ +379 ms] flutter: vertical
[ +384 ms] flutter: vertical
[ +331 ms] flutter: vertical
[ +403 ms] flutter: vertical
[ +431 ms] flutter: vertical
[ +382 ms] flutter: vertical
[ +434 ms] flutter: vertical
[ +433 ms] flutter: vertical
[ +333 ms] flutter: vertical
[+5134 ms] Application finished.

```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
bug flutter analyze
Analyzing bug...                                                        
No issues found! (ran in 1.1s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
flutter doctor -v
[✓] Flutter (Channel beta, 2.0.1, on Linux, locale en_US.UTF-8)
    • Flutter version 2.0.1 at /home/joackim/snap/flutter/common/flutter
    • Framework revision c5a4b4029c (11 days ago), 2021-03-04 09:47:48 -0800
    • Engine revision 40441def69
    • Dart version 2.12.0

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /home/joackim/Android/Sdk
    • Platform android-30, build-tools 30.0.2
    ✗ Android SDK file not found: /home/joackim/Android/Sdk/platforms/android-30/android.jar.
    • Try re-installing or updating your Android SDK,
      visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions.

[✗] Chrome - develop for the web (Cannot find Chrome executable at /home/joackim/chrome-unsafe/google-chrome-unsafe.sh)
    ! /home/joackim/chrome-unsafe/google-chrome-unsafe.sh is not executable.

[✓] Linux toolchain - develop for Linux desktop
    • clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
    • cmake version 3.10.2
    • ninja version 1.8.2
    • pkg-config version 0.29.1

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] Connected device (1 available)
    • Linux (desktop) • linux • linux-x64 • Linux

! Doctor found issues in 3 categories.

```

</details>