tried hot reload but the changes are not reflected on the emulator - flutter

So I pulled this code from my branch and made few changes using vs code and tried hot reload but the changes are not reflected on the emulator. This is a flutter app using dart. I noticed something that said 'source control - 3 unsaved changes'. Does that have to do anything with this?

1)Make sure you are having a stable internet connection, because sometimes the hot reload and code changes does not work when the internet connection is poor.
2)check the current versions of Flutter, IDE(VS code), Emulator. If you are not updated to the latest version that might be an issue because of the bugs, errors are not fixed in the older versions. command for upgrading the flutter is [flutter upgrade or flutter upgrade --force]
3)Finally in this case if the code is not properly formatted then you can't perform the hot reload function. try the flutter command to format code easily, From the terminal just run [flutter format lib] and it will format all the dart files in the lib directory and subdirectory. You can change lib with whatever directory you like.
4)on top of all still the issue is not resolved try to run command [dart fix --dry-run , dart fix --apply] visit the the official documentation of flutter and dart for more references.
5)I hope this will help you to sort out the issue, if not get back to us. Also replay back which method or solution helps you to solve the issue.

Related

Assets audio player doesn't work any more

i use flutter and i used assets_audio_player library to run sounds in my app, it was working fine until last day, when i run the code it gives me PlatformException(OPEN,nul,null,null).
I tried to change the version and also tried to restart the app but nothing worked.
I used AudioWidget.assets() to run the sound, it was working fine but when version 3.0.6 was released it didn't work and gives a rethrow error.
enter image description here
enter image description here
enter image description here
I think it can be an Incompatibility or even some error that could happen with build files being not updated or synchronised.
Just to have a clear conscience, please, on your project terminal, run the very old classic:
flutter clean
Then, run
flutter pub get
Stop your running project and rebuild your application
In fact, if it doesn't solve your problem, i would suggest you to downgrade the assets_audio_player to the previous version to when it was working.
Update me if none of this solve your problem.

Project files can't see library

There are many libraries I use every day from pub and they work. But today I run into a problem with qr_code_scanner. After installing it with flutter pub add qr_code_scanner and running flutter pub get, I get in code:
Same with auto import for classes from this file like QRViewController. What I also did is running flutter upgrade, flutter clean and everything else that came to my mind - still getting this error with that package.
Any other thoughts how can I solve it?
Some of the packages you are using are upgraded to flutter3 and some are still Flutter version < 3. Which is why you might be facing an issue. If you are trying to build an older project I would recommend you to downgrade your package versions which is compatible with flutter < 3 and use flutter version < 3. If you are adding any packages through pub add you might get an error if the pub get is not resolved. Please check the same in terminal.
For anyone who will have the same issue, I found a workaround. I've also tried few other libraries that beside the fact was installed couldn't access them from anywhere in code.
So after all every pub.dev lib is just the code right? You can download the source file and add it into your lib folder. Well, you have to upgrade it manually if needed but at the end it works and that's the main goal!
EDIT:
Another possible solution, as I found out, I did reset my Mac, upgraded environment (VS Code), done flutter clean and flutter pub get and looks like it's working as it should without mentioned workaround so probably the issue was around the coding environment rather than with Flutter and fetched libraries.

Fixing infos error in Flutter project with a command

I have a Flutter project with some Infos(less than warnings) in my console in vsCode.
Like : remove unused imports ..
I got a ton of them after months of work. Is there a way to fix them all with a simple command or any tool ?
Thank you.
You can use
dart fix --apply
The dart fix command finds and fixes two types of issues:
Analysis issues identified by dart analyze that have associated automated fixes (sometimes called quick-fixes or code actions)
Outdated API usages when updating to newer releases of the Dart and Flutter SDKs.
See this doc:
https://dart.dev/tools/dart-fix

Project Template Not Updating on Build

I've been working on a project template today, first time doing so but it has been going alright. I'm almost finished but have now run into some weird issue I can't figure out.
For some reason which I don't know, whenever I try and debug my project template it is now stuck to using some old version of it. No matter what or how much I change then rebuild and try to debug - it still uses some weird old version stuck in some sort of limbo.
I can't seem to figure out where it's finding this file, I've cleared my temp folder. It doesn't show up as installed when I go to Manage Extensions in Visual Studio.
Any ideas what might have happened? There are no errors or warnings.
I was able to solve this by deleting all files inside %LOCALAPPDATA%\Microsoft\VisualStudio\16.0_cfa111feExp\Extensions. After doing so, I restarted VS and loaded up my project and rebuild (not build) the solution.
After that, it now shows the up-to-date version of the project template. What caused this and how to potentially prevent it in the future - I still have absolutely no idea.
I use Visual Studio 2019 Version 16.4.2

Getting Flutter doctor to work

How do I get flutter doctor on my Windows 10 laptop to work, please?
I followed the guidelines here,
Used git to clone the flutter repository,
git clone -b alpha https://github.com/flutter/flutter.git,
Tried adding "C:\Users\<user>\flutter\bin" to my path in the Control Panel
and then in an Admin Powershell, tried executing flutter doctor.
At first, it just hung.
After googling for help, I tried deleting the contents of the
C:\Users\<user>\flutter\bin\cache folder and re-executing flutter doctor but to no avail.
Then, I tried deleting all of flutter and cloning again but flutter doctor just hung again but with, Updating flutter tool.
Tried a few different Googled PATH-adding ideas (that seems to be a complex and disputed area.)
Got a new message: Waiting for another flutter command to release the startuplock
The latest state is that flutter doctor still just hangs but without any message.
I suspect the problem lies in the new Path not being properly recognised (in the registers??)
Can anyone help please?
Well, the issue is not clear enough, but this might be solution, if your flutter doctor is stuck, it might be due to Background Intelligent Transfer Service is disabled, in order to check for yourself, do the following:
Click on the start menu, and then start typing services.
Launch the services and look for Background Intelligent Transfer Service and make sure it is running.
At this stage I believe you will find it disabled for some reason, just right click on it and go to properties and start the service, also change the startup type to automatic.
I can not think of other reasons that might prevent flutter doctor to run for the first time on a Windows machine other than that honestly.
I know this question is a little bit old. Here is a solution that worked for me. Run the Command Prompt as an admin solved the issue for me.
For Windows user check to see if the unzipped flutter folder is read only. (i.e right click the folder then properties then in the attributes section untick the readonly property then apply this change to the folder along with the sub-folders then ok and thats it. Worked for me.
Some errors I got and how I fixed it:
(ERROR 1):
[flutter] flutter doctor -v 'crumb' is not recognized as an internal or external command, operable program or batch file.
Error: Unable to find git in your PATH. exit code 1
(Fix) - Go to flutter installation folder and inside flutter/bin edit the flutter.bat file using a text editor and remove the line (20) that says:
IF EXIST "%mingit_path%" SET PATH=%PATH%;%mingit_path%
The code should look like this on those lines:
REM If available, add location of bundled mingit to PATH
SET mingit_path=%FLUTTER_ROOT%\bin\mingit\cmd
Save and Run flutter doctor and everything should work fine.
(ERROR 2):
flutter doctor takes too long
(Fix) - I downloaded the previous version of the sdk it worked like a charm.
(ERROR 3):
Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to resolve this.
(Fix):
Open Android Studio
Tools Menu, SDK Manager
In the window that comes up there are inner panels, choose SDK Tools panel
Tick Android SDK Command-line Tools
Choose Apply button near the bottom of the window
This worked.
(ERROR 4):
The term 'flutter' is not recognized as the name of a cmdlet, function, script file, or operable program.
(Fix) - Put the correct part in the env variables. I had put D:\flutter instead of D:\flutter\bin. That worked.
I got a solution that worked for me
initially i had downloaded the 2.2.5 SDK which gave the forever run error so i went back and downloaded the previous version ie 2.2.2 it worked like a charm
The Flutter SDK is installed in a protected folder and may not function correctly. Please move the SDK to a location that is user-writable without Administration permissions and restart.