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.
Throw an ApplicationNameNotFoundException if no application name was
provided in the pubspec.yaml
Implementation
String getApplicationName() {
final pubspecFile = File('pubspec.yaml');
if (!pubspecFile.existsSync()) {
throw ApplicationNameNotFoundException();
}
final content = pubspecFile.readAsStringSync();
final yaml = loadYaml(content);
return yaml['name'];
}