package_config
3.0.0, released 5 months ago by tools.dart.dev
Read and write Dart package configuration files.
What it does
Provides APIs to locate, read, and write .dart_tool/package_config.json files. Offers discovery functions and typed models for package configurations. No longer supports legacy .packages files.
AI-written summary of version 3.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to resolve package URIs in tooling or build scripts
- You are building a Dart tool that must read or modify the package configuration
Skip it when
- You only need simple path manipulation without package resolution
- Your project targets Dart versions older than 3.4
Strengths
- Official API that follows the Dart package config spec
- Discovery functions simplify locating config files
- Typed models are sealed and ready for future immutability
Weaknesses
- Only handles package configuration, not a general utility library
- Requires Dart 3.4+, so not usable on older SDKs
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
import 'package:package_config/package_config.dart';
Future<void> main() async {
final result = await findPackageConfigAndFile(Directory.current);
final config = await readConfigFile(result.file);
print('Found ${config.packages.length} packages');
}Alternatives
Packages that do the same job and could replace package_config.
- config
Typed CLI argument and config file parser with env support
84Compare - xcode_parser
Read, modify, and save Xcode project .pbxproj files programmatically
48Compare - resource_portable
Read resource data and files in a portable way across VM, Web, and Flutter.
70Compare - toml
Parse and encode TOML configuration files in Dart.
69Compare
Works with
Packages commonly used together with package_config: ones it builds on, ones built on it, and its own family.
- analyzerBuilt on package_configPerforms static analysis of Dart code for tool integration and embedding.
- dart_styleBuilt on package_configProvides an API and CLI to format Dart source code automatically.
- coverageBuilt on package_configCollects, manipulates, and formats code coverage data in Dart
- testBuilt on package_configA full featured library for writing and running Dart tests across platforms.
- frontend_server_clientBuilt on package_configClient to interact with Dart SDK's frontend_server compiler.
- jniBuilt on package_configProvides Dart/Flutter bindings to call native Java code via JNI.
- dwdsBuilt on package_configProxies between the Chrome debug protocol and the Dart VM service protocol.
- buildBuilt on package_configPackage for authoring build_runner compatible code generators.