Flutter Packages and pub.dev

Nobody builds every feature from scratch. Need a date formatter, a chart, a map, or a login button? Another developer probably solved that problem already and shared the solution as a package. A package is a ready-made bundle of Dart code that your app borrows, like a tool borrowed from a community workshop. Flutter apps rely on packages for almost every real project.

What pub.dev Is

The website pub.dev is the official home of Dart and Flutter packages. Search for a feature, read the documentation, and copy the install command. Every package page shows a score panel, a version history, a list of supported platforms, and example code.


  pub.dev (package store)
        │
        │  flutter pub add intl
        ▼
  pubspec.yaml  ← lists what your app needs
        │
        │  flutter pub get
        ▼
  Downloaded into your project
        │
        │  import 'package:intl/intl.dart';
        ▼
  Ready to use in your Dart files

Packages and Plugins

Two words appear often. A package contains only Dart code, such as a date formatter. A plugin contains Dart code plus native Android or iOS code, such as a camera tool. Both install the same way, and both live on pub.dev.

Adding a Package

Open a terminal inside the project and run one command. Flutter edits pubspec.yaml and downloads the files.


flutter pub add intl

The result inside pubspec.yaml looks like this:


dependencies:
  flutter:
    sdk: flutter
  intl: ^0.19.0

The caret symbol means "this version or any newer version that stays compatible". Flutter picks the newest allowed version when you run flutter pub get.

Using the Package

Import the package at the top of a Dart file and call its features.


import 'package:intl/intl.dart';

String today() {
  return DateFormat('dd MMM yyyy').format(DateTime.now());
}

The call prints a friendly date such as "08 Nov 2026". Writing this formatter by hand would take far longer and miss edge cases.

Useful Commands

CommandPurpose
flutter pub add nameAdds a package
flutter pub remove nameRemoves a package
flutter pub getDownloads everything listed in pubspec.yaml
flutter pub upgradeMoves packages to the newest allowed versions
flutter pub outdatedShows which packages have newer releases

Dependencies and Dev Dependencies

The dependencies section holds packages that ship inside the app. The dev_dependencies section holds helpers used only while building and testing, such as test tools and code checkers. Add a dev package with flutter pub add --dev package_name.

How to Judge a Package

Thousands of packages exist, and quality varies. Check these signals before you commit to one.

SignalWhat to Look For
LikesA higher number shows community trust
Pub pointsA high score means good documentation and clean code
PopularityShows how many projects depend on the package
Last updateRecent releases show active maintenance
PlatformsConfirms support for Android, iOS, web, and desktop
Publisher badgeA verified publisher confirms the owner's identity
LicenseConfirms you may use the code in your app

Look for the "Flutter Favorite" badge as well. The Flutter team awards it to packages with proven quality.

Other Sources

A dependency can point to a folder on your computer or a Git repository. These options suit private team code.


dependencies:
  my_shared_ui:
    path: ../my_shared_ui
  team_tools:
    git:
      url: https://github.com/your-team/team_tools.git

Version Conflicts

Two packages sometimes demand different versions of a third package. The tool prints a long message that names the clash. Run flutter pub upgrade, try a newer version of one package, or remove the package that causes the conflict.

Safe Package Habits

Every package adds code that you did not write and cannot fully inspect. Treat each addition as a decision. Fewer packages mean smaller downloads, fewer updates, and fewer risks. Read the license, review recent issues on the project page, and avoid packages that nobody has updated in years. Keep pubspec.lock in version control, so every teammate builds with identical versions.

Practice Ideas

Add the intl package to a new project and show today's date in a Text widget. Try three different format patterns. Browse pub.dev for a package that shows a loading shimmer, compare two candidates using the signals in the table, and write down which one you would choose and why.