Python Packages & pubspec.yaml: Dependency Management
The Dart package ecosystem is managed through `pub.dev` and the `pubspec.yaml` manifest file. The pubspec defines project metadata (name, version, environment SDK constraints), runtime `dependencies`, development-only `dev_dependencies` (like linters and test frameworks), and assets. Semantic versioning carets (`^2.1.0`) allow non-breaking backwards-compatible upgrades.
"`pubspec.yaml` is the project's official birth certificate and recipe card: it lists the project's identity, supported Dart versions, and all third-party ingredients required to build it."
Deep Dive: How It Works
`pubspec.yaml`: YAML manifest specifying SDK bounds (`sdk: ^3.0.0`) and dependencies.
Caret Syntax (`^1.2.3`): Allows versions from `>=1.2.3 <2.0.0` (semver non-breaking patch and minor updates).
`pubspec.lock`: Auto-generated lockfile recording exact resolved dependency hashes for reproducible builds.
Syntax Blueprint
name: zen_analytics version: 1.0.0 environment: sdk: ^3.3.0 dependencies: http: ^1.2.0 intl: ^0.19.0 dev_dependencies: test: ^1.25.0 lints: ^3.0.0
Standard pubspec.yaml structure with SDK constraints and dependencies.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Putting test libraries or linter packages in `dependencies` instead of `dev_dependencies`.Why it happens: Both work locally, but bloats production package consumers.
How to fix: Place build tools, linters, and test packages strictly inside `dev_dependencies`.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Inspect Package Dependencies
Create a map `final pubspec = {"name": "app", "version": "1.0.0", "sdk": "^3.0.0"};`.
Print `Package: ${pubspec["name"]} (${pubspec["version"]}) for SDK ${pubspec["sdk"]}`.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.