flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.72k stars 27.37k forks source link

MouseRegion not hit tested outside its parent #157303

Open Lootwig opened 4 days ago

Lootwig commented 4 days ago

Steps to reproduce

Run https://dartpad.dev/?id=a408077b04f6090d4b2138c60b5b34bd (both web/windows confirmed)

Expected results

Hovering any part of the box makes it turn orange.

Actual results

Box not turning orange on hover anywhere outside the non-offset coordinates, unless the DecoratedBox widget is removed.

Code sample

Code sample ```dart import 'package:flutter/material.dart'; void main() { runApp(const MainApp()); } class MainApp extends StatelessWidget { const MainApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Colors.grey.shade800, body: Center(child: HoverBox()), ), ); } } class HoverBox extends StatefulWidget { const HoverBox({super.key}); @override State createState() => _HoverBoxState(); } class _HoverBoxState extends State { bool _hovered = false; @override Widget build(BuildContext context) { return DecoratedBox( decoration: BoxDecoration(border: Border.all()), child: Transform.translate( offset: Offset(100, 0), child: SizedBox.square( dimension: 200, child: MouseRegion( onEnter: (_) => setState(() => _hovered = true), onExit: (_) => setState(() => _hovered = false), child: ColoredBox( color: _hovered ? Colors.orange : Colors.blue.withAlpha(100), ), ), ), ), ); } } ```

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output ```console [√] Flutter (Channel master, 3.26.0-1.0.pre.223, on Microsoft Windows [Version 10.0.22631.4317], locale en-US) • Flutter version 3.26.0-1.0.pre.223 on channel master at C:\Users\postd\fvm\versions\master • Upstream repository https://github.com/flutter/flutter.git • Framework revision 8925e1ffdf (4 weeks ago), 2024-09-26 11:52:53 +1200 • Engine revision d6d5fdba6a • Dart version 3.6.0 (build 3.6.0-278.0.dev) • DevTools version 2.40.0-dev.1 [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 35.0.0) • Android SDK at C:\Users\postd\AppData\Local\Android\Sdk • Platform android-35, build-tools 35.0.0 • Java binary at: C:\Users\postd\.jdks\jbr17_0_12\bin\java • Java version OpenJDK Runtime Environment JBR-17.0.12+1-1087.25-nomod (build 17.0.12+1-b1087.25) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.11.5) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.11.35327.3 • Windows 10 SDK version 10.0.22621.0 [!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/to/windows-android-setup for detailed instructions). [√] IntelliJ IDEA Ultimate Edition (version 2024.2) • IntelliJ at C:\Users\postd\AppData\Local\Programs\IntelliJ IDEA Ultimate 3 • 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 [√] VS Code, 64-bit edition (version 1.94.2) • VS Code at C:\Program Files\Microsoft VS Code • Flutter extension version 3.99.20240930 [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.4317] • Chrome (web) • chrome • web-javascript • Google Chrome 129.0.6668.103 • Edge (web) • edge • web-javascript • Microsoft Edge 129.0.2792.89 [√] Network resources • All expected network resources are available. ! Doctor found issues in 1 category. ```
danagbemava-nc commented 4 days ago

Reproducible using the code sample provided above.

https://github.com/user-attachments/assets/e3533cd5-f87b-4903-a5c4-aa60a884fd80

flutter doctor -v ``` [✓] Flutter (Channel stable, 3.24.3, on macOS 15.0.1 24A348 darwin-arm64, locale en-US) • Flutter version 3.24.3 on channel stable at /Users/deanli/dev/stable • Upstream repository https://github.com/flutter/flutter.git • Framework revision 2663184aa7 (6 weeks ago), 2024-09-11 16:27:48 -0500 • Engine revision 36335019a8 • Dart version 3.5.3 • DevTools version 2.37.3 ``` ``` [!] Flutter (Channel master, 3.27.0-1.0.pre.153, on macOS 15.0.1 24A348 darwin-arm64, locale en-US) • Flutter version 3.27.0-1.0.pre.153 on channel master at /Users/deanli/dev/master • Upstream repository https://github.com/flutter/flutter.git • Framework revision 383a221cf3 (3 hours ago), 2024-10-22 06:41:31 +0200 • Engine revision 88288446c3 • Dart version 3.7.0 (build 3.7.0-47.0.dev) • DevTools version 2.40.1 ```