containsEventHandlerAt method

  1. @override
bool containsEventHandlerAt(
  1. Vector2 position
)
override

Whether the game should consume pointer events at the given position, rather than letting them through to the Flutter widgets behind it.

Only consulted when the GameWidget is built with HitTestBehavior.deferToChild; the other behaviors decide without asking the game.

The default returns true, so the game is opaque across its whole surface. To be transparent wherever no component handles input, add the DeferHitTestToComponents mixin, or override this with your own rule.

Implementation

@override
bool containsEventHandlerAt(Vector2 position) {
  for (final component in componentsAtPoint(position)) {
    if (component is PointerInputCallbacks) {
      return true;
    }
  }
  return false;
}