getPubspecInfo static method

String? getPubspecInfo()

Implementation

static String? getPubspecInfo() {
  try {
    String currentDirectory = Directory.current.path;
    String pubspecPath = '$currentDirectory/pubspec.yaml';
    File pubspecFile = File(pubspecPath);
    String contents = pubspecFile.readAsStringSync();
    var yaml = loadYaml(contents);
    return yaml[kName];
  } catch (e) {
    print('Error reading pubspec.yaml: $e');
    return null;
  }
}