Description
Steps to reproduce
- Add a Listener to monitor for mouse wheel events
- Then add a MouseRegion as a child to monitor for hover events
- 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).
- 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:
- I first enable "Capture Pointer" to enable mouse support.
- I then hover over the test area, which causes the test area to turn yellow.
- I then start using the mouse wheel, which you can tell by the
Mouse wheels
counter incrementing. - 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
Flutter Doctor output
Doctor output
[✓] 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!