isExternalPackageLibrary method

Future<bool> isExternalPackageLibrary(
  1. ThreadInfo thread,
  2. Uri uri
)

Checks whether this library is from an external package.

This is used to support debugging "Just My Code" so Pub packages can be marked as not-debuggable.

A library is considered local if the path is within the 'cwd' or 'additionalProjectPaths' in the launch arguments. An editor should include the paths of all open workspace folders in 'additionalProjectPaths' to support this feature correctly.

Implementation

Future<bool> isExternalPackageLibrary(ThreadInfo thread, Uri uri) async {
  if (!uri.isScheme('package')) {
    return false;
  }

  final packageFileLikeUri = await thread.resolveUriToPackageLibPath(uri);
  if (packageFileLikeUri == null) {
    return false;
  }

  return !isInUserProject(packageFileLikeUri);
}