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
  • 91,704
  • 51
  • 240
  • 358

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
  • 91,704
  • 51
  • 240
  • 358