packageMainDirectory property
Implementation
Future<Directory> get packageMainDirectory async {
var packageConfigUri = await Isolate.packageConfig;
if (packageConfigUri == null) {
return Directory.current;
}
var packageConfigFile = packageConfigUri.toFile().absolute;
var dir = packageConfigFile.parent.absolute;
if (dir.name == '.dart_tool') {
dir = dir.parent.absolute;
}
return dir;
}