Skip to main content

flavorspec 0.1.0 copy "flavorspec: ^0.1.0" to clipboard
flavorspec: ^0.1.0 copied to clipboard

Deterministic per-flavor and per-platform dependency overlays and compile-time defines for Flutter and Dart projects.

example/README.md

flavorspec Example Project #

This directory contains a complete example project showcasing flavorspec.

Structure #

  • pubspec.base.yaml: Base pubspec containing shared package metadata and baseline dependencies (http, intl).
  • flavorspec.yaml: Declarative overlay specification defining:
    • Flavors: dev (adds logging) and prod (adds crypto).
    • Platforms: web (adds web) and android (adds path_provider_android).
    • Compile-time defines (API_URL, ENABLE_ANALYTICS, DEFAULT_RENDERER).
  • pubspec.yaml: Generated composite pubspec with a clear header banner.

Command Walkthrough with Real Terminal Output #

1. Inspect Available Flavors & Platforms #

flavorspec list

Output:

Configured Flavors:
  dev
  prod

Configured Platforms:
  web
  android

Active State:
  No flavor currently applied.

2. Preview Changes with Diff (Dry Run) #

flavorspec diff --flavor dev --platform web

Output:

--- pubspec.yaml (current)
+++ pubspec.yaml (flavor: dev, platform: web)
+ # ==============================================================================
+ # DO NOT EDIT - THIS IS A GENERATED FILE
+ # Generated by flavorspec. Source: pubspec.base.yaml + flavorspec.yaml
+ # Active Flavor: dev
+ # Active Platform: web
+ # ==============================================================================
+ 
+ name: flavor_showcase
+ 
+ description: A demonstration project using flavorspec for flavor and platform dependency management.
+ 
+ version: 1.0.0+1
+ 
+ publish_to: none
+ 
+ environment:
+   sdk: ^3.0.0
+ 
+ dependencies:
+   http: ^1.2.0
+   intl: ^0.19.0
+   logging: ^1.2.0
+   web: ^0.5.1
+ 
+ dev_dependencies:
+   lints: ^5.0.0
+   test: ^1.25.0

3. Apply the Flavor and Platform Overlay #

flavorspec apply --flavor dev --platform web

Output:

Applied flavor "dev" (platform: web) to pubspec.yaml.

4. CI Verification with Check #

flavorspec check

Output:

Clean: pubspec.yaml matches expected output for flavor "dev" (platform: web).

If manual edits or unwanted drift occur, flavorspec check exits with a non-zero code and outputs a unified diff.

5. Export Compile-Time Defines #

flavorspec defines --flavor dev --platform web --out defines.json

Output:

Wrote 4 compile-time defines for flavor "dev" to defines.json.

Generated defines.json:

{
  "DEFAULT_RENDERER": "canvaskit",
  "API_URL": "https://dev-api.example.com",
  "ENABLE_ANALYTICS": "false",
  "ENVIRONMENT": "dev"
}

Use with Flutter:

flutter run --dart-define-from-file=defines.json

6. Switch to Production on Android #

flavorspec apply --flavor prod --platform android

Output:

Applied flavor "prod" (platform: android) to pubspec.yaml.
1
likes
160
points
78
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Deterministic per-flavor and per-platform dependency overlays and compile-time defines for Flutter and Dart projects.

Repository (GitHub)
View/report issues

Topics

#build-tools #cli #dependencies #flavors #pubspec

License

MIT (license)

Dependencies

args, crypto, meta, path, pub_semver, yaml

More

Packages that depend on flavorspec