pubspec_manager
4.1.1, released 3 weeks ago by onepub.dev
Type-safe API to read, modify, and write pubspec.yaml while preserving comments.
What it does
pubspec_manager lets you load a pubspec.yaml into a strongly typed object, change any field or comment, and write it back. It keeps all comments and non‑spec content intact.
AI-written summary of version 4.1.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to programmatically update a pubspec and keep comments
- You want a type‑safe interface for pubspec manipulation
- You need to read/write pubspecs in a build script or CI
Skip it when
- You only need simple YAML parsing
- You are working on a very large monorepo where performance is critical
Strengths
- Preserves comments and formatting
- Full support for all documented pubspec keys
- Type‑safe API reduces runtime errors
- Allows access to non‑spec content via Document view
Weaknesses
- No code generation support
- Not a general YAML library
- Limited to pubspec.yaml use cases
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 4
final pubspec = PubSpec.load();
pubspec.version.set('1.2.3');
pubspec.save();Alternatives
Packages that do the same job and could replace pubspec_manager.
- yaml
General YAML parsing without comment preservation
92Compare - pubspec_parse
Simple pubspec parsing but no comment support
93Compare
Works with
Packages commonly used together with pubspec_manager: ones it builds on, ones built on it, and its own family.
- pub_semverpubspec_manager depends on itVersions and version constraints implementing pub's versioning policy.
- stringspubspec_manager depends on itLarge collection of String functions extending the String class and supporting nullable Strings safely.
- dcliBuilt on pubspec_managerA Dart SDK for building cross‑platform command line applications and scripts.
- onepubBuilt on pubspec_managerCommand line tools for the OnePub private Dart and Flutter package repository.
- dart_apitoolBuilt on pubspec_managerAnalyze and diff public APIs of Dart packages to check semantic versioning.
- sidekick_coreBuilt on pubspec_managerShared sidekick commands, plugin engine, migrations, templates, and utilities for custom CLIs.
- pub_releaseBuilt on pubspec_managerAutomates publishing Dart packages to pub.dev, handling version bump, git tags, changelog, and optional dry-run.
- dswitchBuilt on pubspec_managerCLI tool to rapidly switch between channels and versions of standalone Dart.