如何忽略小部件的鼠标悬停事件?

时间:2020-06-25 13:49:06

标签: flutter dart flutter-web

我想(有条件地)防止鼠标悬停事件影响某个小部件(树)。

IgnorePointer

我认为IgnorePointer是基于how you would prevent touch events的解决方案。但是,IgnorePointer不能用于鼠标悬停。


如何防止鼠标悬停事件影响我的小部件?

1 个答案:

答案 0 :(得分:0)

您可以在Stack中使用展开的MouseRegion来吸收窗口小部件的所有鼠标悬停事件:

Stack(
  children: [
    child, // <---- your widget that ignores mouse hover events.
    const MouseRegion(
      child: SizedBox.expand(),
    ),
  ],
);