updatePubspecValue static method

Future<void> updatePubspecValue(
  1. String newValue
)

Implementation

static Future<void> updatePubspecValue(String newValue) async {
  // Construct the path to pubspec.yaml
  final pubspecPath = 'pubspec.yaml';

  // Read the contents of pubspec.yaml
  final pubspecFile = File(pubspecPath);
  final content = pubspecFile.readAsStringSync();

  // Parse the YAML content using YamlEditor
  final editor = YamlEditor(content);

  // Update the value associated with the key
  editor.update(['version'], newValue);

  // Write the updated content back to pubspec.yaml
  pubspecFile.writeAsStringSync(editor.toString());
}