private void initLivePackageNameToDirMap() {
    final VirtualFile baseDir = myPubspecYamlFile == null ? null : myPubspecYamlFile.getParent();
    if (myPubspecYamlFile == null || baseDir == null) return;

    final String name = PubspecYamlUtil.getDartProjectName(myPubspecYamlFile);
    final VirtualFile libFolder = baseDir.findChild(PubspecYamlUtil.LIB_DIR_NAME);

    if (name != null && libFolder != null && libFolder.isDirectory()) {
      myLivePackageNameToDirMap.put(name, libFolder);
    }

    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();

    PubspecYamlUtil.processPathPackages(
        myPubspecYamlFile,
        new PairConsumer<String, VirtualFile>() {
          @Override
          public void consume(
              @NotNull final String packageName, @NotNull final VirtualFile packageDir) {
            if (fileIndex.isInContent(packageDir)) {
              myLivePackageNameToDirMap.put(packageName, packageDir);
            }
          }
        });
  }
  @Nullable
  private VirtualFile initPackageRootsAndReturnPubspecYamlFile(
      final @NotNull VirtualFile contextFile) {
    final Module module = ModuleUtilCore.findModuleForFile(contextFile, myProject);
    if (module == null) return null;

    final VirtualFile[] customPackageRoots = DartConfigurable.getCustomPackageRoots(module);
    if (customPackageRoots.length > 0) {
      Collections.addAll(myPackageRoots, customPackageRoots);
      return null;
    }

    final VirtualFile pubspecYamlFile = PubspecYamlUtil.findPubspecYamlFile(myProject, contextFile);
    final VirtualFile parentFolder = pubspecYamlFile == null ? null : pubspecYamlFile.getParent();
    final VirtualFile packagesFolder =
        parentFolder == null ? null : parentFolder.findChild(PACKAGES_FOLDER_NAME);
    if (packagesFolder != null && packagesFolder.isDirectory()) {
      myPackageRoots.add(packagesFolder);
    }

    return pubspecYamlFile;
  }