packageMainDirectory property

Future<Directory> get packageMainDirectory

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;
}