getFilePathFromImportLine static method

String getFilePathFromImportLine(
  1. String importLine
)

Retrieves the file path from the import line importLine of a package.

Implementation

static String getFilePathFromImportLine(String importLine) {
  final searchString = 'package:$appPackageName/';

  final fromIndex = importLine.indexOf(searchString) + searchString.length;
  int toIndex = importLine.lastIndexOf("'");
  if (toIndex == -1) toIndex = importLine.lastIndexOf('"');

  final dependency = importLine.substring(fromIndex, toIndex);
  return path.join(Utils.projectDirectory, 'lib', dependency).trim();
}