getProjectName method

Future<String?> getProjectName()

Get project name from pubspec.yaml

Implementation

Future<String?> getProjectName() async {
  final pubspecPath = p.join(projectRoot, 'pubspec.yaml');
  try {
    final content = await FileUtils.readFile(pubspecPath);
    final pubspec = loadYaml(content);
    return pubspec['name'] as String?;
  } catch (e) {
    return null;
  }
}