Dart/Flutter
Support for Dart and Flutter projects using pubspec.yaml.
Table of contents
- Supported Files
- Registry
- Dependency Format
- Version Specification
- Special Cases
- SDK Constraints
- Vulnerability Database
- Example pubspec.yaml
- Tooling Integration
- Troubleshooting
Supported Files
| File | Description |
|---|---|
pubspec.yaml |
Dart/Flutter manifest |
Registry
pub.dev - The official Dart package repository
- Base URL:
https://pub.dev/api - Rate limit: ~100 requests per minute
- Documentation: pub.dev
Dependency Format
Regular Dependencies
dependencies:
http: ^1.1.0
provider: ^6.0.0
dio: ^5.0.0
Development Dependencies
dev_dependencies:
test: ^1.24.0
build_runner: ^2.4.0
json_serializable: ^6.7.0
Dependency Overrides
dependency_overrides:
http: ^1.2.0
Version Specification
Dart uses caret syntax similar to npm:
| Syntax | Meaning |
|---|---|
1.0.0 |
Exactly 1.0.0 |
^1.0.0 |
>=1.0.0, <2.0.0 |
">=1.0.0 <2.0.0" |
Range |
any |
Any version |
Special Cases
Flutter SDK
dependencies:
flutter:
sdk: flutter
SDK dependencies show → SDK hint.
Git Dependencies
dependencies:
my_package:
git:
url: https://github.com/user/repo.git
ref: main
Git dependencies show → Git hint.
Path Dependencies
dependencies:
my_local_package:
path: ../my_local_package
Path dependencies show → Local hint.
Hosted Dependencies
dependencies:
my_package:
hosted:
name: my_package
url: https://my-package-server.com
version: ^1.0.0
Custom hosted packages are resolved from their specified URL.
Retracted Versions
Retracted versions on pub.dev show ⊘ Retracted hint. Update immediately.
Discontinued Packages
Discontinued packages show ⚠ Discontinued hint. Find an alternative.
SDK Constraints
environment:
sdk: ">=3.0.0 <4.0.0"
flutter: ">=3.10.0"
SDK constraints are shown but don’t trigger version hints.
Vulnerability Database
Dart vulnerabilities are sourced from:
- GitHub Security Advisories
- OSV.dev Dart database
Example pubspec.yaml
name: my_app
description: A Flutter application
version: 1.0.0
environment:
sdk: ">=3.0.0 <4.0.0"
flutter: ">=3.10.0"
dependencies:
flutter:
sdk: flutter
http: ^1.1.0 # ✓
provider: ^6.0.0 # -> 6.1.0
dio: ^5.0.0 # ✓
riverpod: ^2.4.0 # ✓
dev_dependencies:
flutter_test:
sdk: flutter
test: ^1.24.0 # ✓
build_runner: ^2.4.0 # -> 2.4.6
json_serializable: ^6.7.0 # ✓
Tooling Integration
After updating pubspec.yaml with Dependi:
# Dart
dart pub get
dart pub upgrade
# Flutter
flutter pub get
flutter pub upgrade
# Check outdated
dart pub outdated
flutter pub outdated
Troubleshooting
Package Not Found
- Verify package name spelling
- Check if package exists on pub.dev
- Ensure network access to pub.dev
Version Resolution Failures
- Check SDK constraints compatibility
- Review transitive dependency conflicts
- Try
dart pub upgrade --major-versions
Flutter vs Dart Packages
Some packages are Flutter-specific:
- Flutter packages require Flutter SDK
- Pure Dart packages work in both
- Check package description on pub.dev
Retracted Version Warning
If using a retracted version:
- Check the package’s changelog for issues
- Update to a newer version immediately
- The retraction reason may be in the package’s README