getApplicationName method
Reads the pubspec.yaml file and returns the application’s name.
Returns null if the pubspec.yaml file is missing or cannot be parsed.
Implementation
String? getApplicationName() {
final pubspecFile = File('pubspec.yaml');
if (!pubspecFile.existsSync()) {
return null;
}
final content = pubspecFile.readAsStringSync();
final yaml = loadYaml(content);
return yaml['name'];
}