pathPackageConfigMapGetPackagePath function
Get a library path, you can get the project dir through its parent
Implementation
String? pathPackageConfigMapGetPackagePath(
String path, Map packageConfigMap, String package,
{bool? windows}) {
var packagesList = packageConfigMap['packages'] as Iterable;
for (var packageMap in packagesList) {
if (packageMap is Map) {
var name = packageMap['name'];
if (name is String && name == package) {
var rootUri = packageMap['rootUri'];
if (rootUri is String) {
// rootUri if relative is relative to .dart_tool
// we want it relative to the root project.
// Replace .. with . to avoid going up twice
if (rootUri.startsWith('..')) {
rootUri = rootUri.substring(1);
}
return _toFilePath(path, rootUri, windows: windows);
}
}
}
}
return null;
}