Flutter Re-create

Paul Senni
2 min readDec 16, 2018

--

Hello flutter-verse,

So imagine this, you are working on a flutter project and all is well, you are adding dependencies to your pubspec.yaml, you’ve event set up hot reload to fire up every time to save your work, all is well. Then all of a sudden, you get a weird error you can’t really explain, you spend the rest of the day reading questions, answers, issues and comments on StackOverFlow and GitHub with no luck. Heck you even dive over to Gitter and twitter to ask around and get nothing other that basically narrowing down the source of the issue to the underlying native platoform (iOS or Android).

Such was the case that I wrestled with a few days ago. What made thing worse for me was that I took every advice I found on the internet (the lesson here is don’t do this, huge no-no), so what was once a single failed to compile multidexfile turned to incompatible gradle version and this went on for a while, and things only got worse to a point where I was stuck between a rock and a hard place, I had messed up my gradle files with weird lines of code I did not really understand.

Introducing flutter create

As I was considering starting another project I stumbled upon a help tip on the flutter CLI man pages.

When I ran flutter create this popped up:

No option specified for the output directory. Create a new Flutter project.
If run on a project that already exists, this will repair the project, recreating any files that are missing.

Then it hit me, what if i just start over, (I didn’t have much to lose at this point, I had screwed things up pretty bad).

The Solution.

I deleted the Android folder from the root folder, then I navigated to the root of my project and ran flutter create . basically telling flutter to try and repair all the damaged and / or missing files in my project.

A second later, flutter recreated my android folder and all I had to do was to run flutter run for the project to recompile and everything was fixed. All I had to do at this point was just add back all the dependencies I was using like the firebase plugin and other gradle dependencies.

The lesson.

The take away here is, if you get stranded and have already messed up to a point of no return, then you might want to consider asking flutter to help out in repairing the damage you have done.

That’s all I have got for now, happy coding…

Thanks!

--

--