enclosingPackage property
The Package that encloses this package, if any.
A package is considered to be the enclosing package if this package is located in a direct child directory of the enclosing package.
Implementation
late final Package? enclosingPackage = () {
final enclosingPackagePath = p.dirname(path);
return _packageMap.values.firstWhereOrNull(
(package) => p.equals(package.path, enclosingPackagePath),
);
}();