Repository: flutter
Issue: MouseRegion hover event fired even after restricting touch in the hitTestSelf function
Labels: framework,f: gestures,a: mouse,has reproducible steps,P2,found in release: 2.2,found in release: 2.5,team-framework,triaged-framework

Hi,  

I have wrapped custom widget to the MouseRegion widget. I'm using the boolean value returned by the hitTestSelf method to control the touch interaction. The problem is that the mouse region onHover event is still fired after the hitTestSelf function returns false. The expected behavior is that the mouse region events won’t fire when hitTestSelf function returns false. 

**Expected behavior:** MouseRegion interaction methods won't fired when return false in hitTestSelf method. It only fires when return true.
**Actual behavior:** MouseRegion interaction methods fired even return false in the hitTestSelf method.

It happens in web and windows platforms. I'm not checked in macOS platform.

```
class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Directionality(
        textDirection: TextDirection.ltr,
        child: CustomWidget(),
      ),
    );
  }
}

class CustomWidget extends StatefulWidget {
  _CustomWidgetState createState() => _CustomWidgetState();
}

class _CustomWidgetState extends State<CustomWidget> {
  @override
  Widget build(BuildContext context) {
    return MouseRegion(
      onEnter: (PointerEnterEvent event) {
        print('OnEnter');
      },
      onHover: (PointerHoverEvent event) {
        print('OnHover');
      },
      onExit: (PointerExitEvent event) {
        print('OnExit');
      },
      child: _CustomWidgetRenderObject(),
    );
  }
}

class _CustomWidgetRenderObject extends LeafRenderObjectWidget {
  @override
  _RenderCustomWidget createRenderObject(BuildContext context) {
    return _RenderCustomWidget();
  }

  @override
  void updateRenderObject(
      BuildContext context, _RenderCustomWidget renderObject) {}
}

class _RenderCustomWidget extends RenderBox {
  @override
  bool hitTestSelf(Offset position) {
    if (position.dx < 200) {
      return true;
    }
    return false;
  }

  @override
  void performLayout() {
    size = Size(400, 400);
  }

  @override
  void paint(PaintingContext context, Offset offset) {
    super.paint(context, offset);
    Paint paint = Paint()
      ..color = Colors.green
      ..style = PaintingStyle.fill;

    context.canvas.drawRect(Rect.fromLTWH(0, 0, 200, 400), paint);
    paint.color = Colors.red;
    context.canvas.drawRect(Rect.fromLTWH(200, 0, 200, 400), paint);
  }
}
```

C:\flutter\flutter> flutter doctor -v
[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19042.1110], locale en-US)
    • Flutter version 2.2.3 at C:\flutter\flutter
    • Framework revision f4abaa0735 (7 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\TempKaruna\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0-25-microsoft-b00)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Professional 2019 16.10.3)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional
    • Visual Studio Professional 2019 version 16.10.31424.327
    • Windows 10 SDK version 10.0.19041.0

[!] 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/windows#android-setup for detailed instructions).

[√] Connected device (4 available)
    • Pixel XL (mobile) • HT6A60207219 • android-arm64  • Android 10 (API 29)
    • Windows (desktop) • windows      • windows-x64    • Microsoft Windows [Version 10.0.19042.1110]
    • Chrome (web)      • chrome       • web-javascript • Google Chrome 92.0.4515.131
    • Edge (web)        • edge         • web-javascript • Microsoft Edge 92.0.902.67


Is there any way to resolve this? 

Thanks in advance.