Skip to content
pubscout

pubspec_yaml

3.1.0, released 5 years ago by dart-borg.dev

Access and manipulate content of pubspec.yaml files in Dart.

WASM-ready
$ flutter pub add pubspec_yaml
Source repository

What it does

Provides a data type representing the contents of a pubspec.yaml file. Allows importing from YAML strings, inspecting fields and dependencies, manipulating data, and exporting back to YAML strings.

AI-written summary of version 3.1.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to parse and analyze pubspec.yaml files programmatically in a Dart script or tool.
  • You want to inspect package dependencies, SDK constraints, or custom fields from a pubspec.yaml file.

Skip it when

  • You are writing a standard Flutter application and do not need to parse project metadata files.

Strengths

  • Supports equality operations and lenses via functional_data.
  • Handles custom fields via a JSON-like Map structure.

Weaknesses

  • Limited to reading and manipulating pubspec.yaml file structures.
  • Relies on external packages like functional_data and json2yaml.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
7

Add pubspec_yaml to your dependencies.

void main() {
  final pubspecYaml = File('pubspec.yaml').readAsStringSync().toPubspecYaml();
  print(pubspecYaml.name);
}

Alternatives

Packages that do the same job and could replace pubspec_yaml.

Works with

Packages commonly used together with pubspec_yaml: ones it builds on, ones built on it, and its own family.