fromActivatedLine static method

PubGlobalPackage? fromActivatedLine(
  1. String line,
  2. String packageName
)

Get global package from actived line.

Implementation

static PubGlobalPackage? fromActivatedLine(String line, String packageName) {
  final activated = 'activated';
  if (line.toLowerCase().startsWith(activated)) {
    final start = line.indexOf(packageName, activated.length);
    if (start != -1) {
      line = line.substring(start);
      // removing ending . if any
      if (line.endsWith('.')) {
        line = line.substring(0, line.length - 1);
      }
      final updatedPackage = PubGlobalPackage.fromListLine(line);
      return updatedPackage;
    }
  }
  return null;
}