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) =>
// TODO: use the distance function defined on the node class instead
// a.distance(node).compareTo(b.distance(node))
_distance(a.position, node.position)
.compareTo(_distance(b.position, node.position)));
return overlapping;
}