Packages, Plugins, And Pub
A Dart package adds Dart code. A Flutter plugin adds Dart API plus target-specific implementation code. That difference matters for rebuilds, tests, and release risk.
Package Types
| Type | Example use | Risk |
|---|---|---|
| Dart-only package | Pure validation, date handling, models | API churn, transitive dependencies |
| Flutter UI package | Widgets, charts, design components | Visual quality, accessibility, maintenance |
| Plugin | Camera, file picker, notifications, preferences | Platform support, permissions, native build failures |
| Federated plugin | Shared interface with separate target implementations | Missing implementation for a target |
| FFI package | Native library bridge | ABI, packaging, signing, platform support |
Dependency Gate
Before adding a dependency, record:
| Check | Why |
|---|---|
| pub.dev score and maintenance | Avoid abandoned packages |
| supported platforms | Prevent surprise web/desktop failures |
| latest release and changelog | Spot stale APIs and breaking changes |
| native permissions and setup | Avoid hidden manifest/Info.plist/store policy work |
| license | Keep distribution safe |
| existing alternatives | Avoid dependency sprawl |
Add Workflow
flutter pub add package_name
flutter pub get
flutter analyze
flutter test
If the package has native code, fully restart the app and test each target platform that matters.
Gotcha:
flutter pub addcan be correct and still break iOS pods, Android Gradle, web builds, or desktop packaging. Dependency changes are platform changes until proven otherwise.