pubspec_runtime 0.0.2 copy "pubspec_runtime: ^0.0.2" to clipboard
pubspec_runtime: ^0.0.2 copied to clipboard

A Dart package that provides a simple way to manuplate the pubspec.yaml file at runtime.

example/pubspec_runtime_example.dart

import 'package:pubspec_runtime/pubspec_runtime.dart';

void main() async {
  final pubspecEditor = PubspecEditor();

  print("Dependencies:");
  print(pubspecEditor.dependencies.list);

  print("Dev Dependencies:");
  print(pubspecEditor.devDependencies.list);

  print("Adding a dependency...");
  pubspecEditor.dependencies
      .add(Dependency(name: 'http', version: '^0.13.3', isDev: false));

  print("Adding a dev dependency...");

  pubspecEditor.devDependencies
      .add(Dependency(name: 'http', version: '^0.13.3', isDev: true));

  print("Add a key value pair to the `pubspec.yaml` file.");
  pubspecEditor.add("author", "John Doe");

  print("Get the value of a key from the `pubspec.yaml` file.");
  print(pubspecEditor.get("author"));

  print("Remove a key value pair from the `pubspec.yaml` file.");
  pubspecEditor.remove("author");

  print("Updated Dependencies:");
  print(pubspecEditor.dependencies.list);

  print("Saving changes...");
  pubspecEditor.save();

  print("Changes saved successfully!");

  print("Running pub get...");
  runPubGet()
      .then((value) => print(
          "Pub get executed successfully with exit code: ${value.exitCode}"))
      .catchError(
          (error) => print("Error occurred while executing pub get: $error"));
}
1
likes
160
pub points
0%
popularity

Publisher

unverified uploader

A Dart package that provides a simple way to manuplate the pubspec.yaml file at runtime.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on pubspec_runtime