If you're a mobile application developer, you've probably worked with Flutter, the popular cross-platform application development framework.
As Flutter evolves and updates, it's important to keep applications up-to-date to take advantage of the latest features and improvements and also to make preventive fixes as new versions are released.
In this article, we'll explore how to update an existing Flutter application and some tips for doing so effectively.
Updating an old Flutter project seems like a simple task... until you run into deprecated pubs, exploding Gradle, Android or iOS incompatibilities, and syntax errors which—to be honest—are usually the least of your worries.
It has happened to me more than once: the app worked perfectly a couple of years ago and suddenly it won't even compile. That's why I put together this practical, complete, and updated guide so you can migrate any Flutter project without suffering more than necessary.
1. Verify the Current Flutter Version
Before starting, verify the current Flutter version in your project. Open a terminal and run the following command:
flutter --versionThis will show you the current version of Flutter installed on your system. If you don't have the latest version, update Flutter by running:
flutter upgradeIf the project hasn't been touched for a while, it's normal for it to come from old versions (1.x, 2.x...). This results in dozens of warnings and incompatible changes.
In my case, old projects usually break as soon as I run the first flutter run.
Status of your dependencies and pubs
The most frequent problems appear here: deprecated packages, duplicates, abandoned plugins, or versions that do not support the current platform.
I usually see errors like:
- "X package is deprecated"
- "Incompatibility with Android embedding v2"
- "Plugin doesn't support current Gradle version"
Sometimes it's enough to update, other times you have to replace the package because the author abandoned it.
Major changes between versions (breaking changes)
Flutter has periods where it makes big changes: migration to null safety, Material 3, renaming of widgets, changes in TextTheme, etc.
Checking in advance which APIs changed prevents hours of blind testing.
2. Update Flutter SDK and Update the pubspec.yaml File
First, update our environment to the latest version of Flutter:
$ flutter upgrade $ flutter doctorThe pubspec.yaml file is essential for managing your application's dependencies. Open this file in your code editor and look for the dependencies section. This is where the libraries and packages used in your project are specified.
3. Run flutter pub get
After updating the dependencies in the pubspec.yaml file, run the following command in the terminal:
flutter pub getThis will download the latest versions of the dependencies and integrate them into your project; also if you use VSC you can open the mentioned file and press Control + S.
As a recommendation, you can remove the versions for all dependencies so that it downloads the latest versions of the packages you want to update.
Update Dependencies: Check if there are updates available for your application's dependencies. You can check the pub.dev page to verify the latest versions of the packages you use. Update the versions in your
pubspec.yamlfile as needed, this step is optional depending on how you develop your Flutter applications, if you do not specify a version for the packages, you don't have to do anything in this step.
If you want to do it step by step, to see the available versions:
$ flutter pub outdatedTo update:
$ flutter pub upgrade --major-versions
4. Check Compatibility
Before implementing the changes, verify that your application remains compatible with the new versions of the dependencies. Run your application and perform thorough tests to ensure everything works as expected.
Usually this step is not very necessary because if there is a change in any of the packages, the app simply won't run on the emulator and will clearly indicate the error that is happening. So, the application successfully launching on the emulator is a good sign that the app did not suffer any problem when updating the packages, even so, it is a good idea to run unit tests or simply test the app.
5. Update the Code
If there are specific changes in your code related to the updates, be sure to implement them correctly. This may include syntax adjustments, method updates, or changes in your application's logic; for example:
- FlatButton → TextButton
- Theme.of(context).textTheme.title → titleMedium
- Migration of Material 3 styles
- Classes moved to new imports
Migrate to null safety in an old project
If the project comes from before null safety, run:
$ dart migrateHow to update Gradle plugin and gradle-wrapper
This is one of the points that breaks the most.
- Modern Android Plugin
- Compatible Gradle
- MinSdk and targetSdk aligned
If you use an old plugin, Android Studio will throw errors even before compiling.
Frequent errors when compiling on Android
Some you will surely see:
- "Unsupported class file major version" → Incorrect Java
- "You are applying Flutter's Gradle plugin imperatively" → Very old project
- "This version of Gradle is not supported" → Obsolete wrapper
What I always do:
cd android && ./gradlew clean && ./gradlew buildIf something fails here, it's the native configuration, not Flutter.
Final checks and production build
Project cleanup and complete rebuild
Before the final build:
$ flutter clean
$ flutter pub get
$ flutter build apk --releaseUpdate app signature and keystore if necessary
If the keystore is lost or corrupted, you need to generate a new one:
keytool -genkey -v -keystore ~/upload-keystore.jks \ -keyalg RSA -keysize 2048 -validity 10000 -alias uploadFinal checklist before updating
- Dependencies updated
- Correct Gradle and Java
- App opens on Android and iOS
- All critical warnings resolved
- Release build generated without errors
Frequently asked questions about updating Flutter projects
- Why won't an old Flutter project compile?
- Almost always due to incompatibilities between Flutter/Gradle/Java or an abandoned plugin.
- How to know which dependency is causing problems?
- Run flutter pub outdated and check the build error on Android: it usually points it out directly.
- Does Dart fix fix everything?
- No. It fixes 70%. The rest is manual.
- Is it necessary to migrate to null safety?
- Yes. Not doing so will prevent compiling on new versions of Flutter.
✅ Conclusion
Updating a Flutter project is not difficult... but it's not a magic click either.
With deprecated pubs, native incompatibilities, and big changes between versions, more than once I've found myself fixing things that seemed simple but ended up failing on Android without explanation.
Even so, by following an organized route—SDK → dependencies → code → Android/iOS → build—you can migrate any project, no matter how old it is.
I agree to receive announcements of interest about this Blog.
We mention some simple steps to update the packages that correspond to your application in Flutter and with this, update a project in Flutter.