From Flutter 1.22.5 to Flutter 3
Tags: flutter, mobile, android, ios
Published: 2022-05-14 13:39:02

I have a pet project that I wrote some time ago in 2020, in order to put together some content and guidance (mainly for my own usage) about Flutter development architecture using BLOC and MVI. You can find the first article here:
 
https://thasaquino.medium.com/flutter-reactive-architecture-with-bloc-and-mvi-part-1-94bec725f2eb

So now Flutter 3 was released and was about time to update that project :D
I will share in this article the steps that I faced in order to have my project updated, maybe may serve as someone that can have the same need. So let's go.

First of all, I run "flutter doctor" to check how far I was from the latest version and to check my outdated setup. Then had to run "flutter upgrade" in order to, as the name says, upgrade :) Had to update also things regarding Android and Xcode setup, but was pretty straightforward following the suggestion from Flutter doctor command.
So my setup was finally looking good to go:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vnbbeeamddwp5k2jdf5u.png)

Next step was to run "dart migrate" and then of course I had issues because of some libraries I was using with old versions that were not supporting yet null safety functionality.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9d89yta9lntkbsidstov.png)

To see what null safe package versions were available, I just had to run "dart pub outdated - mode=null-safety". So you can see in the figure that is pretty clear what needs to be upgraded.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/py2qcnddnhlhtxteh2z8.png)

Then, to properly start using newer versions with null safety support, I had to run "dart pub upgrade - null-safety", and by using this command my pubspec.yaml got updated as following:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p1l8q73ebrr4tqkibfa1.png)

After that, I only got warnings regarding my own files and followed the suggestions on how to fix the issues:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t12eovg2fr3kjo4xz76u.png)

One thing to mention is that I had to replace the use of: Scaffold.of(context).showSnackBar(snackBar) with ScaffoldMessenger.of(context).showSnackBar(snackBar).

ScaffoldMessenger brings improvements on the snack bar usage and how it gets persisted between Scaffold transitions.

Another thing I had to update was regarding Android embedding. On Flutter 2 it got some improvements in order to work better for cases where you need to use the Add-to-app feature. Provides better support when your FlutterActivity is not the first and only Android Activity in the application.

Reference: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
And then voilà, my app was building again and now with Flutter 3 :)     

Here is the branch that has the changes: https://github.com/tasaquino/mvi_flutter_example/tree/updating-to-flutter3

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/arwktcjbp5ccbj8a6ymk.png)