findNodesAtPosition method

List<Node> findNodesAtPosition(
  1. Offset position
)

Finds all nodes at a position defined in the box's coordinates.

Use this method with caution. It searches the complete node tree to locate the nodes, which can be slow if the node tree is large.

List nodes = mySpriteBox.findNodesAtPosition(new Point(50.0, 50.0));

Implementation

List<Node> findNodesAtPosition(Offset position) {
  List<Node> nodes = <Node>[];

  // Traverse the render tree and find objects at the position
  _addNodesAtPosition(_rootNode, position, nodes);

  return nodes;
}