The Flutter team at Google has recently released version 2.10 of the popular cross-platform development framework. I wrote about Flutter and the advantages of using it over other frameworks in this post. If you have existing Flutter apps, and you want to upgrade them to the latest version, you may run into issues that you haven’t encountered before (at least that’s what happened with me!). In this blog post, I want to write about a build error that you may encounter after upgrading to the latest version.
The Upgrade
First of all, to actually do the upgrade, you can perform these steps:
- Make sure you are on the stable channel. To do that, run this command
flutter channel
in a terminal window to see which channel you’re currently on. If you are not on stable, you can run this command to switch to the stable channelflutter channel stable
. Please note that the stable channel is the recommended one because (as the name indicates!) you will get the most stable version of Flutter. - Run this command to upgrade to the latest version
flutter upgrade
.
The Error
After you upgrade, you may get this error when you try to run your app:
Error: Member not found: 'packageRoot'
If you do get this error, then here are a couple of steps you can perform to fix it.
The Fix
I’m going to list the steps that I had to take to fix the error. However, it is very likely that the last step is the only step that you need.
- Make sure that all of your packages in
pubspec.yaml
are up to date. - In a terminal window, run
flutter clean
and thenflutter pub get
. If you still get a build error at this point, try the next step. - Run
flutter pub upgrade
. This will update all your packages, along with their dependancies to the latest version. This step fixed it for me, and I was able to run my app without a build error.
I hope you found this helpful. And, if you have any questions, please don’t hesitate to post them in the comments here, or send me an email through my contact page. Happy coding!