flutter / flutter/flutter

[iOS] Mouse wheel is changing localPosition for Listener and MouseRegion which is causing hover state issues and mouse wheel events to be lost

Open
#169,885 9 comments 0 reactions 0 assignees View on GitHub
a: mouse found in release: 3.32 found in release: 3.33 framework has reproducible steps P2 platform-ios team-ios triaged-ios
Dominant language
Dart
Stars
179k
Forks
31.1k
PR merge metrics
PR metrics pending

Description

### Steps to reproduce

1. Add a Listener to monitor for mouse wheel events
2. Then add a MouseRegion as a child to monitor for hover events
3. Build the Flutter app for iOS and run on a device that supports a mouse such as an iPad or a Mac (Designed for iPad).
4. Hover the mouse over the Listener/MouseRegion and continuously and quickly rotate the mouse wheel in one direction.

The shorter the parent container, the quicker the issue will arise. This is because the mouse wheel is altering the localPosition on Listener/MouseRegion events for every mouse wheel rotation. Which is then causing the localPosition to look like it is outside of the widget even though it is still over the widget.

This only recently started being an issue after upgrading to Flutter 3.32.0. It was working fine when running Flutter 3.24.3.

### Expected results

The MouseRegion remains in the hovered state (onExit should not be triggered) because the mouse remains over the widget. And, all mouse wheel events are successfully triggered via the Listener.

### Actual results

The MouseRegion sometimes loses the hover state because onExit gets triggered. And, sometimes mouse wheel events are missed, which usually corresponds with the hover state issue. Using the DartPad sample below, you can see that localPosition.dy changes for every mouse wheel even if the pointer stays in the same spot.

This issue does not occur when running on web or Android. This can be verified by running the DartPad sample below. It only happens on iOS.

### Video

Here is a video of the bug using an iPad simulator:
https://drive.google.com/file/d/1y3X-DQakgolQ9Twbse5RpRn0siO-wReX/view

In the video:
1. I first enable "Capture Pointer" to enable mouse support.
2. I then hover over the test area, which causes the test area to turn yellow.
3. I then start using the mouse wheel, which you can tell by the `Mouse wheels` counter incrementing.
4. You can then see the test area turn back to silver periodically, which is the bug. The mouse pointer is still over the test area, so it should remain yellow even when using the mouse wheel.

### Code sample

Code sample

[DartPad sample app](https://dartpad.dev/?id=41478aa93214a888db57d42d62ff7e0a)

### Flutter Doctor output

Doctor output

```console
[✓] Flutter (Channel stable, 3.32.0, on macOS 15.5 24F74 darwin-arm64, locale en-US) [1,087ms]
• Flutter version 3.32.0 on channel stable at /Users/BKVX46/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision be698c48a6 (2 weeks ago), 2025-05-19 12:59:14 -0700
• Engine revision 1881800949
• Dart version 3.8.0
• DevTools version 2.45.1

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [2.8s]
• Android SDK at /Users/BKVX46/Library/Android/sdk
• Platform android-35, build-tools 35.0.0
• Java binary at: /Users/BKVX46/Library/Java/JavaVirtualMachines/jbr-17.0.12/Contents/Home/bin/java
This JDK is specified in your Flutter configuration.
To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment JBR-17.0.12+1-1207.37-nomod (build 17.0.12+1-b1207.37)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1) [1,539ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16B40
• CocoaPods version 1.16.2

[✓] Chrome - develop for the web [13ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [12ms]
• Android Studio at /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 21.0.6+-13368085-b895.109)

[✓] VS Code (version 1.100.2) [10ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.110.0

[✓] Network resources [381ms]
• All expected network resources are available.

• No issues found!
```

Contributor guide

Open the contributing guide

Research direction

Start with the linked DartPad sample and reproduce the behavior on iOS using a mouse or simulator. Trace how Listener and MouseRegion handle pointer and wheel events, then verify that hover remains active and all wheel events are delivered while the pointer stays over the widget.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter, ios
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.