getOverlapping method
input: the node that we want to get the overlapping nodes with returns a list of nodes that are overlapping with the input node sorted by closest to farthest from the input node
Implementation
List<Node<E>> getOverlapping(Node<E> node) {
List<Node<E>> overlapping = [];
for (Node<E> n in _nodes.cast<Node<E>>()) {
Offset offset = node.position - n.position;
if (offset.dx.abs() < boxSize.width &&
offset.dy.abs() < boxSize.height &&
idProvider(node.data) != idProvider(n.data)) {
overlapping.add(n);
}
}
overlapping.sort((a, b) => a
.distance(node)
.distanceSquared
.compareTo(b.distance(node).distanceSquared));
return overlapping;
}