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
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.
- pubspec_parse
Alternative package for parsing pubspec.yaml files.
93Compare
Works with
Packages commonly used together with pubspec_yaml: ones it builds on, ones built on it, and its own family.
- yamlpubspec_yaml depends on itA Dart library for parsing YAML documents into Dart data structures.
- functional_datapubspec_yaml depends on itAnnotations and helper lenses for generating boilerplate for immutable data types.
- json2yamlpubspec_yaml depends on itConverts JSON maps to YAML strings with beautification and pubspec conventions.
- sum_typespubspec_yaml depends on itA code generator that adds algebraic sum‑type support to Dart.
- plain_optionalpubspec_yaml depends on itAn implementation of an Optional type in Dart, similar to Swift.