Skip to content
pubscout

package_config

3.0.0, released 5 months ago by tools.dart.dev

Read and write Dart package configuration files.

$ flutter pub add package_config
Source repository

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.

Works with

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