setPubspecVersion function

void setPubspecVersion(
  1. File pubspecFile,
  2. Version version
)

Sets the version in the pubspec.yaml file

Implementation

void setPubspecVersion(File pubspecFile, Version version) {
  final editor = YamlEditor(pubspecFile.readAsStringSync());
  editor.update(['version'], version.toString());
  pubspecFile.writeAsStringSync(editor.toString());
}