my flutter project creates folders build 1, build 2, build 3 etc - flutter

It does not affect anything but size of project - hence git push takes forever.
I already tried deleting it once but it appears again once flutter run and continues where it stopped making new folders with every fresh run or so.
I am using MacOS
Let me know if you need more information!
Appreciate any help!

So apparently my mac optimized the storage and deleted some (unused) parts of the project which triggered flutter to make the new folders. In the end I needed to compress the whole project to be able to move it on the internal disk (somewhere on user) and then deleted all extra folders with the initial folders. I then ran the command flutter create . to create all folders. After a flutter clean it was running without any problems or creating extra folders.
Lesson learned: never create a flutter project within iCloud Drive folders.

Related

Unverified breakpoint in VSCode in Flutter

My debug mode does not work as I see the unverified breakpoint notice in VSCode in debug mode.
I already checked the Launch json file and it is fine, but something else is wrong which I do not see what it is. Maybe something related to paths, etc.
I tried to make a new project in VSCode using the command and the new default Flutter project is OK.
So it seems like, if I can make a fresh project from my current project then my problem could be solved. But how? I tried to move my files from my current project to the newly made Default Flutter project but I do not think this is the way. Because I guess some of the files in my project are the source of issues...
I already deleted .vs file but no help.
Do you have any good idea how to fix this issue?
First try cleaning the project files using flutter clean then flutter pub get, try running the app without debugging and if you are down for making a new one just move the lib and assets folders and copy the content of pubspec.yaml file.

Flutter failed to delete a directory at "build\flutter_assets"

I've never had this error. The error doesn't appear when I run "flutter run -d chrome" for the initial flutter example but when I add a couple of folders this error appears. thank you for the help
Flutter failed to delete a directory at "build\flutter_assets". The flutter tool cannot access the file or directory.
Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.
The build folder is auto-generated when flutter runs. If you created the flutter_assets folder in the build folder, move it to the assets folder instead. (I mixed up the assets and flutter_assets folders in my head.)
I had this issue and wound up manually deleting the entire build folder and running flutter clean (see other suggestions here on SO and here on GitHub).

How to delete then reinstall Flutter

Whenever I have a problem with Flutter I often find answers saying 'reinstall the Flutter SDK'.
However I cannot find any clear instructions on how to do this (please direct me to them if I am wrong).
General Questions
By 'clear' instructions, I mean ones that answer the following questions:
What folder(s) should be deleted to remove Flutter from my computer?
Do any files need to be copied and added to the new Flutter folder once I reinstall it?
Do I need to make any changes to my Flutter projects either before or after reinstalling Flutter?
Will I need to download the same channel (stable, beta, dev, master) as what I am currently on?
Will I need to make any changes to my PATH?
Are these the correct steps to reinstall?
Go to https://flutter.dev/docs/development/tools/sdk/releases?tab=macos
Download the zip of the release you want (safest to use latest stable version)
Open Flutter zip in SAME location as the previous Flutter folder was
Done - I should now be able to run Flutter projects without any further steps
Apologies if these seem like very basic questions but for someone fairly new it isn't obvious what the answers are.
I'm new to Flutter and had similar issues. I will outline what worked for me but meanwhile, to answer your questions:
What folder(s) should be deleted to remove Flutter from my computer?
The Flutter folder which you unzipped and, presumably added to $PATH. Although not deleting it isn't going to pose an issue. I have separate folders of different versions of Flutter on my computer and it's fine.
Do any files need to be copied and added to the new Flutter folder
once I reinstall it?
Try a fresh download of Flutter and unzip it? There is no need to copy or add any files to the Flutter folder once you've (re)installed it.
Do I need to make any changes to my Flutter projects either before or
after reinstalling Flutter?
Not exactly sure what you mean by make changes to your Flutter projects. If you ran flutter doctor and didn't get any errors, then it's good to go. When you create a new Flutter project either in Android Studio, VS Code or Terminal, it will automatically handle whatever file copying business.
Will I need to download the same channel (stable, beta, dev, master)
as what I am currently on?
No, you only need one. I suggest you download one from Stable unless you need web support, which would be Beta.
Will I need to make any changes to my PATH?
After you've unzipped your fresh copy of Flutter (note the folder destination), open Terminal and change the path to said folder destination but make sure it's the /bin folder you're mapping to.
Are these the correct steps to reinstall?
Go to
https://flutter.dev/docs/development/tools/sdk/releases?tab=macos
Download the zip of the release you want (safest to use latest stable
version) Open Flutter zip in SAME location as the previous Flutter
folder was Done - I should now be able to run Flutter projects without
any further steps
Yes and no. You're missing a number of steps. Please follow the full Flutter installation guide depending on your OS.
It took me about 10 hours over two days and a VPN to finally get it working in China with an old install from two years ago when I was in Montréal.

Flutter: How to backup flutter project without build directory?

I want to make a complete backup of the Flutter project, and I noticed the build folder is the biggest one.
Size Details:
Total App Size: 889.6 MB
Build Directory: 743 MB
Remaining directories, including ios, android, assets and lib: 146 MB
I think, zipping project excluding build directory would be considered full backup and it will contain everything needed to start again.
Q. Is that correct? (if I'm wrong then is there any way to reduce app size?)
Delete build folder.
Delete Pod folder from IOS Directory
.gradle folder from android Directory
& if you have release & build folder in Android then delete it
Run Command: Fluter Clean
Now Folder will be 1MB to 10MB, depending on assets folder size.
To start with i would suggest git versioning with an online (public or private) repository as a good way to back up your code. To answer your Question, There's absolutely no problem with leaving out the build folder, Actually almost by default git will ignore the build folder. Note that every time you compile the app, that build folder is refreshed, actually its always good to start by cleaning it
In IntelliJ idea base ides (like Android Studio), you can get a lightweight .zip backup from your code.
Just follow this path in the top menu:
File> Export> Project to Zip File

Issue while moving flutter app from ios to windows and vice versa [duplicate]

This question already has answers here:
copy project / folder flutter to another computer
(3 answers)
Closed 4 years ago.
I have created flutter app on ios device, built and ran successfully on simulator.
I have taken that code to my windows machine. When I opened the project on visual studio code, I get following error.
main.dart issue
after running flutter clean, I get this error(it seems that on ios machine the flutter path is different then on windows)
flutter clean
When I move app created in windows to ios, by changing the paths in .packages file, I was able to remove the error but the files and folders which I had added and referenced in main.dart file, the project was unable to locate that.Even the intellisense doesn't show my files.
Basically I want to know the way maintain my code which I can reuse on both environment.
Thanks,
You need to run flutter packages get when you move the code from one machine to another.
Actually you should delete all directories and files listed in .gitignore.
These files contain machine specific paths that likely don't match from one machine to another.
Using git to pass changes (clone/commit/pull) would do this automatically.
A related issue Improve error output for projects copyied from another machine. #26014