Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix flutter corrupted files?

Sorry in advance, I am fairly new to flutter and my explanation is not very concise.

I am having a problem with corrupted flutter files. My project was fine until a while ago when some of the files corrupted I think. I think it might have to do with me changing the projects file name to make different versions but because of this some of files have gone into some strange format.

Any help would be appreciated to either fix this or prevent it in the future!

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, v1.10.3-pre.66, on Microsoft Windows 
[Version 10.0.18362.356], locale en-ZA)

[√] Android toolchain - develop for Android devices (Android SDK version 
28.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 3.5)
[√] Android Studio (version 3.5)
[√] VS Code (version 1.35.0)
[√] Connected device (2 available)

• No issues found!

Here is an example of what the code looks like

{"isEntrypoint":true,"deps":[],"parts": 
["quiver|lib/src/iterables/concat.dart",
"quiver|lib/src/iterables/count.dart", 
"quiver|lib/src/iterables/cycle.dart",
"quiver|lib/src/iterables/enumerate.dart 
","quiver|lib/src/iterables/infinite_iterable.dart"
 ,"quiver|lib/src/iterables/ 
 merge.dart","quiver|lib/src/iterables/min_max.dart"
 ,"quiver|lib/src/iterables/partition.dart"
 ,"quiver|lib/src/iterables/generating_iterable.dart"
 ,"quiver|lib/src/iterables/range.dart"
 ,"quiver|lib/src/iterables/zip.dart"]
 ,"conditionalDeps":[],"sdkDeps":["collection"],"hasMain":false}  

Another file

// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=C:\flutter\flutter
FLUTTER_APPLICATION_PATH=C:\Users\parko\AndroidStudioProjects\flutter_web
FLUTTER_TARGET=lib\main.dart
FLUTTER_BUILD_DIR=build
SYMROOT=${SOURCE_ROOT}/../build\ios
FLUTTER_FRAMEWORK_DIR=C:\flutter\flutter\bin\cache\artifacts\engine\ios
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1

Pubspec.yaml file

  {"isEntrypoint":
    false,"deps": 
   ["crypto|lib/src/digest.dart","crypto|lib/src/digest_sink.dart"
   ,"crypto|lib/src/hash.dart"],"parts":[],"conditionalDeps": 
  [],"sdkDeps": 
  ["convert","typed_data"],"hasMain":false}

It seems like random code so I assume it corrupted but hopefully someone will be able to help me restore my older code.:)
As a result it gives me this error

 Error: No pubspec.yaml file found.
 This command should be run from the root of your Flutter project.
 Do not run this command from the root of your git clone of Flutter.

I don't know if it would contribute to the problem but every time I open certain projects it gives me this error

Load Settings
Cannot load settings from file 
C:\Users\parko\AndroidStudioProjects\
exp_appv0.3\.idea\exp_appv0.3.iml'': ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
Please correct the file content

I have tried to fix this problem but so far I have had no success. Thanks -Matt

UPDATE: I switched from Android Studio to Visual Studio code and the files for the project were returned back to normal, I am still not quite sure why this happened but switching from Android Studio to Visual Studio code fixed the problem.

like image 304
MattTheXPat Avatar asked Oct 02 '19 18:10

MattTheXPat


2 Answers

  1. Close Android Studio
  2. Delete caches folder in : C:\Users<USER NAME>.AndroidStudio4.0\system
  3. Open Android Studio.

That's it.

like image 191
Vipul Gupta Avatar answered Sep 28 '22 20:09

Vipul Gupta


I am not sure if it's a fix for everybody or not but what I do in this situation is that I open the file in text editor and save it without any addition. Android Studio then corrects the gibberish that it was showing earlier and the correct file is loaded.

like image 26
Abdul Rahman Shamair Avatar answered Sep 28 '22 19:09

Abdul Rahman Shamair