3-Flutter update? Flutter problems! — The web coder path to Flutter

After the Flutter Interact, I couldn’t wait to get the latest update, but when I did, I couldn’t run my project!

CodeGlich
Flutter Community
5 min readDec 14, 2019

--

I was expecting to make my third article about something else, but I chose to take this opportunity to show some of the struggles I find.

Previous article:

I come from a ASP.NET background, most of the code I do has little to it that could make it break between framework/visual studio updates.

The same can’t be said on Flutter since we use packages, which some times rely on other dependencies, things can break between SDK changes, that is what I found out.

Note: this article was written before “flutter_map” was updated to 8.0. You can now use 8.0 without any problems related to this package.

Right after upgrading to the newest SDK version, for some reason I can’t run my project anymore.

red problem

So like any programmer, I googled! I found some people with the same problem, one, and two. But I didn’t find a clear answer on how to solve my problem.

I could understand it was “flutter_map” related, and something related to loading an Image.

I’m going back to that “flutter_map” page and see if there is a new version for it. Nothing yet, but I noticed this “Dependencies” thing, so maybe it’s a problem with one of those… there is one called “cached_network_image“ and another called “flutter_image”, both mentioned on the error above.

dependencies

I added the first dependency to the “pubspec.yaml” file manually, this will force it use another version of that dependency:

code 0

Nothing special happens, and I still get the same error, what about changing “flutter_image”?

flutter image version

When I save and get the packages, I see this message:

something new

That’s new, ok, from that message it says “flutter_map” needs “flutter_image” dependency set to “^2.0.0”, I do that, and get packages again.

code 0

Did I solve the problem?

No!

I still get the same ugly error I did at the start, but I noticed there is another version on the tabs page, “2.0.1”

another flutter image version

Could that give me a different result?

≥ min SDK < max SDK

Interestingly, it does, it is now talking about the SDK version, so this is a problem caused by the Flutter SDK upgrade?

I’m going to need to downgrade the SDK to find out. How do I do that?!

flutter cmd list

Calling flutter on command line gives me a list of useful commands, there is a “flutter version” command to change the SDK version. Since the message I got before gave a choice between “requires Flutter SDK version >=1.5.9-pre.94 <1.10.15-pre.144”.

I’m going to check out what releases they’ve on GitHub.

Flutter SDK versions

Guess I’m going with the one version right bellow the supported, I will run “flutter version v1.9.1+hotfix.6”

downgrading…

This might take a while.

… and done!

After doing a version downgrade, I got a lot of errors on my dart code, closing the IDE and opining again fixed this.

And guess what? downgrading the SDK fixed my problem! The app runs again!

I can now remove the “flutter_image: ^2.0.1” I had added earlier (because it is a dependency, it will be added automatically), and it runs like before.

What does this mean?

In short, I can’t use the latest SDK on this project yet, not while the packages I’m using don’t updated and are compatible with the latest SDK.

Can’t I have the latest SDK?

Not on this project at least, I guess I can have multiple Flutter versions on my PC, and switch between them while I’m working on different projects, for that I will need to update manually my Flutter SDK path (example on visual studio code):

open dart settings

search for “flutter sdk path”:

sdk path

and edit it:

new (old) sdk path

Save, close IDE, open IDE again, and you will be running the new SDK on the path.

When working on another project, you will need to change this back to the proper SDK folder.

What else should I do?

If you work with a team, you should start declaring the compatible SDK on your “pubspec.yaml” file, so that everyone knows which SDK version it was tested for:

declaring Flutter SDK version

How do I upgrade back to the newest SDK?

You will need to set the flutter channel to “stable” again (check here for channels/versions), and run “flutter upgrade” after that

changing flutter channel
flutter upgrade

Lessons?

Be careful when upgrading your SDK, be aware that when you upgrade, you might break things, you will need to check everything still works. Do your work first, upgrade later!

--

--