relativePackageUri function

String relativePackageUri(
  1. Package package
)

Returns the package URI root path relative to the package root directory.

Implementation

String relativePackageUri(Package package) {
  final rootPath = package.root.toFilePath();
  final packageUriRootPath = package.packageUriRoot.toFilePath();
  final relative = p.relative(packageUriRootPath, from: rootPath);

  return p.normalize(relative).endsWith(p.separator)
      ? p.normalize(relative)
      : '${p.normalize(relative)}${p.separator}';
}