How I Update an Old Flutter Project's Packages Without Breaking It
A step-by-step way to upgrade packages in an old Flutter project: read flutter pub outdated, fix version solving failed, upgrade Firebase packages together and replace discontinued packages.
By Yaqoob Developer · · 7 min read
- #Flutter
- #Dart
- #Packages
- #pub
- #Firebase
Some time ago I opened one of my old Flutter projects that I hadn't touched in a long while. As soon as I ran it, warnings and package update notices started showing up, so I decided to update the packages. That turned into a longer job than I expected: a version solving failed error, Firebase packages that had to move together, old methods that stopped compiling, and one package that simply didn't work with the new Flutter version any more.
This post is the process I use now, based on what went wrong for me. It is slower than upgrading everything with one command, but when something breaks, I know exactly which package caused it.
In this guide you will learn:
- How to see which packages are out of date, and by how much
- Why I stopped using
--major-versionson old projects - How to read a
version solving failederror - How to upgrade Firebase packages without a mess
- What to do when a package is discontinued or no longer maintained
Step 0: Commit before you touch anything
Before changing a single version, commit your project (or copy the folder if you don't use Git). An upgrade can change pubspec.yaml, pubspec.lock and your code at the same time. With a commit you can always go back to a version that worked.
git add .
git commit -m "Before package upgrades"
Step 1: See what is out of date
Run this in the project folder:
flutter pub outdated
You get a table like this:
Package Name Current Upgradable Resolvable Latest
http *0.13.6 *0.13.6 1.6.0 1.6.0
Each column answers a different question:
- Current: the version your app uses now (from
pubspec.lock). - Upgradable: what
flutter pub upgradecan give you without editingpubspec.yaml. - Resolvable: the newest version that works with all your other packages, if you edit
pubspec.yaml. - Latest: the newest version on pub.dev.
When Upgradable is lower than Latest, your version constraint is holding the package back. For example http: ^0.13.6 allows any 0.13.x, but never 1.x.
Only have the pubspec.yaml? If the project doesn't build yet, or you just want a quick look, paste the file into my free Pubspec Checker. It shows the latest version of every package, flags discontinued ones and packages that haven't had a release in years, and gives you an updated pubspec to copy.
Step 2: Take the safe updates first
flutter pub upgrade
Without any flags, this only moves packages within the ranges in your pubspec.yaml. These are bug fixes and small features, and they rarely break anything. Run the app after this step. If it works, commit again. Now any problem that appears later comes from the major upgrades, not from these.
Step 3: Major upgrades, one package at a time
A new major version (for example http 0.13 → 1.x, or google_fonts 5 → 6) is allowed to make breaking changes. This is where old projects break.
From my experience: I used to run
flutter pub upgrade --major-versionsand update everything in one go. On one old project that gave me a lot of errors at once, and I couldn't tell which package had caused which problem. Now, on old projects, I update the important packages one by one and run the app after each update. It's slower, but finding the problem is much easier.
You can still use --major-versions, just for one package at a time:
flutter pub upgrade --major-versions http
This updates the constraint in pubspec.yaml for http only. Then:
- Read the package's changelog on pub.dev for the versions you skipped. Breaking changes are usually listed with what to use instead.
- Run
flutter analyzeto see every place in your code that no longer compiles. - Fix those, run the app, and commit.
- Move on to the next package.
Want to see what an upgrade would change before it happens? Add --dry-run:
flutter pub upgrade --major-versions http --dry-run
Step 4: When you see "version solving failed"
This is the error I hit first. It means pub can't find one set of versions that satisfies every package at the same time. Here is a real one, from a project that still pins an old http but upgraded google_fonts:
Because google_fonts >=4.0.5 depends on http ^1.0.0 and my_app depends on http ^0.13.6, google_fonts >=4.0.5 is forbidden.
So, because my_app depends on google_fonts ^6.2.1, version solving failed.
It looks scary, but read it as two sentences:
- New
google_fontsneedshttp1.x. - My app says
httpmust stay on 0.13.x, so the two can't both be true.
The fix is to move one side: raise http to ^1.0.0 (and fix any code that breaks), or keep the older google_fonts for now. Recent versions of pub print these suggestions for you, right under the error.
From my experience: At first I didn't understand which package was the problem. When I read the error slowly, it turned out two packages wanted different versions of the same dependency: after I updated one of them, the other started conflicting with it. I kept changing versions and checking with
flutter pub getandflutter pub outdated. I even had to downgrade a few packages before the dependencies finally resolved.
Two more commands that help here:
# Show which package depends on which (find who needs the conflicting one)
flutter pub deps
# After a big Flutter upgrade, start the resolution from scratch
flutter clean
flutter pub get
You might also see dependency_overrides suggested online. It forces a version even when packages disagree. It can get you unstuck for a moment, but it hides a real conflict and can break the app at runtime, so I'd treat it as a temporary last resort, not a fix.
Step 5: Upgrade Firebase packages together
Firebase packages (firebase_core, firebase_auth, cloud_firestore, firebase_storage and the rest) are released as a set and depend on each other. Upgrading only one of them is a common cause of version conflicts.
From my experience: Firebase packages have given me the most trouble. Once I updated
firebase_core, and then I had to check the versions of all the other Firebase packages too. After that, some old methods in my app started giving errors. At first I thought the package was broken, but it turned out my code needed changes for the new version.
So upgrade them in one step, naming every Firebase package your app uses:
flutter pub upgrade --major-versions firebase_core firebase_auth cloud_firestore
Then run flutter analyze. Errors here usually mean an API was renamed or removed in the new version, not that the package is broken. The FlutterFire changelog for each package lists the breaking changes and what replaces them. If you use Firebase Authentication, my Firebase login and sign-up guide shows the current way to write it.
Step 6: Packages that are discontinued or unmaintained
Some packages stop being updated. On pub.dev, the author can mark a package as discontinued, often with a suggested replacement. Others are never marked, they just haven't had a release in years and stop working with new Flutter versions.
From my experience: In one old project I found a package that hadn't been updated for a long time and didn't work properly with the new Flutter version. First I tried running it with different versions of the same package, but the problem stayed. Then I searched pub.dev for an alternative and switched to another package that is maintained. Replacing it took some time too, because I had to change the old package's methods in my code by hand.
When you choose a replacement on pub.dev, check:
- Last published date: a release in the last few months is a good sign.
- Likes and pub points: popular, well-scored packages get fixed faster.
- Verified publisher: shows who maintains it.
- Platforms: make sure it supports Android, iOS and anything else your app targets.
To keep the change manageable, wrap the package in one small class of your own (for example a StorageService) and call that class from your screens. The next time you have to swap the package, you only change one file.
My checklist for an old project
- Commit first.
flutter pub outdated(or paste the pubspec into the Pubspec Checker).flutter pub upgrade, run the app, commit.- Major upgrades one package at a time: read the changelog,
flutter analyze, fix, run, commit. - Upgrade all Firebase packages together.
- Replace discontinued or long-unmaintained packages with maintained ones.
- If you see
version solving failed, read it as two sentences and move one side.
Summary
flutter pub outdatedtells you how far behind each package is; Resolvable vs Latest shows what is holding it back.- Take the safe updates first, then do major upgrades one at a time so you always know what broke.
version solving failedmeans two packages want different versions of the same dependency: read the error, then raise or lower one of them.- Upgrade Firebase packages as a set, and expect small code changes, not a broken package.
- Replace discontinued packages with maintained ones, and wrap them in your own class so the next swap is easy.
If you are setting up a fresh machine before opening the old project, start with my guide to installing Flutter on Windows and macOS.
Keep reading
More articles
· 9 min read
How I Drew a Product Bottle in Flutter with CustomPainter (No Images)
Draw a realistic product bottle in Flutter with CustomPainter: a Path with cubic curves, gradient shaders for matte metal, clipPath details and a floating shadow. Step by step, with the full code from my water bottle shop UI.
· 10 min read
Swipe to Log In Button in Flutter (No Package)
Build a swipe to log in button in Flutter from scratch: drag the knob, spring back under 80%, show a check on success. Step by step, with the full code from my crypto wallet login UI.
· 6 min read
How to Publish a Flutter App on Google Play: Step-by-Step Checklist
A complete checklist for publishing your Flutter app on Google Play: app signing, the release App Bundle, store listing images, Data safety, content rating, testing tracks and the 12-tester rule for new accounts.