error when using flutter with Android Studio - flutter

If you use flutter in android studio, all the Widget ls colored with yellow(some color) and some times they recommend commands. Mine worked too, but after resetting flutter sdk, it doesn't work. At first, I thought sdk was wrong, but there's nothing wrong with running code.
For example, if you make code like this,
'build' and 'ThemeData' are colored with yellow.
And if you type 'Colors.' then it recommends some colors which you can use.
However, in my android studio.. it does not works.
I also check my preferences but I can't find the reason.

Try restarting Android Studio and your computer
Also, check if dart and flutter SDKs are properly configured for the project.
If all this seems good, check if you have accidentally uninstalled Flutter or Dart plugin in Android Studio, if yes install again and restart Android Studio.
If they are already installed try reinstalling them and restart Android Studio.
I hope this fixes your problem.

Related

Avdmanager not found

I am trying to run my first flutter app emulator, which is having complications at various level, I have tried too much but could not make through it, here is what I have tried.
On trying to click on Create Android Emulator in Visual studio code, the dart extension shows following:-
link to img
I don't know why it is happening as on checking, it is present:-
link to img.
I would like to point out here that I am not able to understand what I have to put in flutter --android-sdk {path}.
Also on running flutter doctor, it shows the absence of visual studio despite the fact that I have it in place(that is why I could take the first screenshot). One thing I would like to point out here is that my vscode is in C drive while my flutter-test folder(which contains everything related to flutter) is in D drive:
link to img
Please help so that I can further follow along to create an android app. Also ask if any further information is needed.
You need to know that having Android Studio Installed will solve the majority of issues caused.
STEPS:
Clean out all your Flutter, Dart and Android installation
Download Android Studio from official website (the latest version is Android Studio Electric Eel)
After the installation of Android Studio, open it and add the flutter and dart plugins
Now download flutter and follow the installation steps.
After adding flutter, go to Edit the system environment on your PC and add JAVA_HOME variable with C:\Program Files\Android\Android Studio\jbr. Noticed I used jbr not jre because with Android Studio Electric Eel jbr replaced jre.
Afterward, open new terminal and run flutter doctor --android-licenses
WHAT DID WE DO ABOVE?
We cleaned our installation and downloaded the latest Flutter version which has Dart downloaded automatically. Next, we Installed Android Studio Electric Eel which has Java and Android settings in-build. This way we solve 99% of the problems here: The last thing is to create an Emulator using Android Studio not VSC.
For future help, please comment below. Bye

Breakpoints not working with Flutter in Android Studio

I can set breakpoints, but when I run in Debug mode the breakpoint's icon change with this:
I think that the problem is the new version of Flutter plugin in Android Studio, but I'm not sure. How to fix this?
What I've tried:
flutter clean
android studio cache clean and restart
Upgrade to the latest version of the flutter plugin 65.1.3 solved my problem.
https://plugins.jetbrains.com/plugin/9212-flutter/versions
need to roll back the version of the flutter plugin to 64.1.2.
https://plugins.jetbrains.com/plugin/9212-flutter/versions
Confirmed: plug-in was one thing.
The other problem is that IntelliJ (same for Android Studio) distinguish between:
import '../../viewmodel/**m**essages
import '../../viewmodel/**M**essages
Compiling, running, Dart analysis ... everything's fine. However, breakpoints don't work!
To be more precise: some breakpoints don't work, only in some files!
Tip: If a breakpoint does not work, remove all imports in the file. Click the bulb to get suggestions - and you will see the duplicate imports.
See wrong imports
Btw.: I am on Windows. And the file system does not distinguish between upper and lower case filenames.
Faced to this issue today as well: looks like for me the solution was to update Flutter / Dart SDK and their Plugins for Android Studio.
Some users report the problem is linked to the Chrom Version >=100 due to API change, but on my side it was not working with Edge as well.
After update problem has gone
There is indeed also an issue with Chrome Version >=100. Running flutter upgrade (to flutter 2.10.5) fixed this for me as described here

The refactoring option is gone after dart last update, what can I do, I tried restarting and uninstalled Visual Studio Code but nothing happened

Click on the image description.
Worked for me on beta as well. It's a bit less cutting edge than dev so might be better for some uses.
flutter channel beta
flutter upgrade
Also found out that turning off the previewLSP setting in the VSCode Dart & Flutter extension settings turns the refactoring menu back on. There seems to be a disagreement between LSP mode and refactoring that is fixed in later versions. If you don't want to upgrade you can try turning that setting off and then restarting VSCode.
Run flutter doctor, if flutter and dart are up to date then try switching to a different flutter channel and update flutter and dart again. It worked for me recently.
Try switch to dev channel,
flutter channel dev
flutter upgrade
I sugest to re-install the flutter plugin for VSCode (wich includes dart). See if it helps.

Showing the emulator

I want to learn and script Flutter and I installed the vscode and also extensions of Flutter. But I do not know the continuation of the process of installing such as showing the emulator and stuff.
How to solve this problem?
For Android setup, you need to install Android Studio and its plugins about Dart and Flutter, and for iOS setup, install Xcode too. And then you can start an emulator or a simulator. For more info, read the official document.

Flutter- Creating an android emulator for my app

I wrote an app, and now I want to test on a Android environment,but when I press debug, no emulator is shown. I clicked on create new emulator, and It says creating new emulator, but nothing happens after that. Also, I tried to connect my phone to use it as an emulator but It wasn't being found by visual studio code. I am a beginner so please, any helps
Try to reinstall flutter SDK and don't forget to install flutter plugin on your editor (Android Studio or VsCode), Depending on your OS follow one of this instruction, it's so simple to install.
https://flutter.io/docs/get-started/install