isInUserProject method

bool isInUserProject(
  1. String targetPath
)

Checks whether path is inside the users project. This is used to support debugging "Just My Code" (via isExternalPackageLibrary) and also for stack trace highlighting, where non-user code will be faded.

Implementation

bool isInUserProject(String targetPath) {
  // Always compare paths case-insensitively to avoid any issues where APIs
  // may have returned different casing (e.g. Windows drive letters). It's
  // almost certain a user wouldn't have a "local" package and an "external"
  // package with paths differing only be case.
  targetPath = targetPath.toLowerCase();
  return projectPaths
      .map((projectPath) => projectPath.toLowerCase())
      .any((projectPath) => path.isWithin(projectPath, targetPath));
}