Skip to content

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

Open
@scott1055

Description

@scott1055

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

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: mouseIssues related to using a mouse or mouse supportfound in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions