1

I want to (conditionally) prevent mouse hover events from affecting a certain widget (tree).

IgnorePointer

I thought that IgnorePointer would be the solution here, based on how you would prevent touch events. However, IgnorePointer does not work for mouse hovering.


How do I prevent mouse hover events from affecting my widget?

creativecreatorormaybenot
  • 114,516
  • 58
  • 291
  • 402

1 Answers1

1

You can use an expanded MouseRegion in a Stack to absorb all mouse hover events for your widget:

Stack(
  children: [
    child, // <---- your widget that ignores mouse hover events.
    const MouseRegion(
      child: SizedBox.expand(),
    ),
  ],
);
creativecreatorormaybenot
  • 114,516
  • 58
  • 291
  • 402