getProjectName static method

String getProjectName()

  1. Get Project Name

Implementation

static String getProjectName() {
  final file = File(_pubspecPath);
  if (!file.existsSync()) {
    throw Exception(
      'pubspec.yaml not found. Run this inside a Flutter project.',
    );
  }
  final content = file.readAsStringSync();
  final yamlMap = loadYaml(content) as Map;
  return yamlMap['name']?.toString() ?? 'unknown_project';
}