getVersionFromPubspec method
Implementation
Future<String> getVersionFromPubspec() async {
if (!await project.pubspecExists()) {
throw NoPubspecFileFound(
'No pubspec.yaml found.',
);
}
final contents = await project.getPubspecContents();
Map yaml;
try {
yaml = await loadYaml(contents) as Map;
} catch (e) {
throw StateError('The pubspec.yaml does not appear to be valid.');
}
final version = yaml['version'];
if (version is! String) {
throw StateError('Could not find "version" key on pubspec.yaml');
}
return version;
}