findNode method

dynamic findNode(
  1. dynamic root,
  2. int width,
  3. int height
)

Implementation

findNode(root, int width, int height) {
  if (root['used'] != null) {
    final rightNode = this.findNode(root['right'], width, height);
    if (rightNode != null) {
      return rightNode;
    }
    final downNode = this.findNode(root['down'], width, height);
    if (downNode != null) {
      return downNode;
    }
  } else if ((width <= root['width']) && (height <= root['height']))
    return root;
  else
    return null;
}