contentAtPath method

  1. @override
SearchResult contentAtPath(
  1. Path path, {
  2. int partialPathStart = 0,
  3. int partialPathLength = -1,
})

Implementation

@override
SearchResult contentAtPath(Path path,
    {int partialPathStart = 0, int partialPathLength = -1}) {
  _logger.finest('contentAtPath ( path : $path )');

  if (partialPathLength == -1) {
    partialPathLength = path.length;
  }
  _logger.finest('partialPathLength ( $partialPathLength )');

  var result = SearchResult();
  result.approximate = false;

  Container? currentContainer = this;
  RuntimeObject currentObj = this;

  for (var i = partialPathStart; i < partialPathLength; ++i) {
    var comp = path.getComponent(i);

    _logger.finest('comp : $comp');

    // Path component was wrong type
    if (currentContainer == null) {
      result.approximate = true;
      break;
    }

    var foundObj = currentContainer.contentWithPathComponent(comp);

    // Couldn't resolve entire path?
    if (foundObj == null) {
      _logger.finest("Couldn't resolve entire path?");
      result.approximate = true;
      break;
    }

    currentObj = foundObj;
    currentContainer = asOrNull<Container>(foundObj);
  }

  result.obj = currentObj;

  return result;
}