Skip to content
pubscout

config

0.10.0, released 5 days ago by serverpod.dev

Typed CLI argument and config file parser with env support

$ flutter pub add config
Source repository

What it does

Extends Dart's args package to provide typed options, environment variable integration, YAML/JSON config files, and comprehensive validation. It offers a drop‑in replacement for ArgParser via ConfigParser.

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

Use it when

  • Migrating an existing ArgParser setup to support typed options and multiple config sources
  • Building command‑line tools that need environment variable or file based configuration
  • Requiring consistent, fail‑fast error reporting for CLI arguments

Skip it when

  • Projects that only need simple flag parsing and are already using args without the need for env or file support

Strengths

  • Typed option definitions with automatic parsing and constraints
  • Support for environment variables and YAML/JSON config files
  • Collects all validation errors upfront for better UX
  • Drop‑in replacement for ArgParser with minimal code changes

Weaknesses

  • Requires Dart SDK 3.9+ (breaking change in 0.10.0)
  • addCommand() not supported, needs BetterCommandRunner from cli_tools
  • No code generation support

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
7

Add dependency, import config, replace ArgParser with ConfigParser; no build_runner needed

import 'package:config/config.dart';
final parser = ConfigParser();
parser.addOption('port', defaultsTo: '8080');
parser.addOption('host', envName: 'HOST');
final results = parser.parse(['--port', '3000']);
print(results['port']);

Alternatives

Packages that do the same job and could replace config.

Works with

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