New Flutter project runs in command line but not VScode - visual-studio-code

I have recently reinstalled Flutter, Android SDK and VSCode.
I start the AVD emulator successfully.
I run Flutter Doctor from the Command line successfully.
I run Flutter create successfully.
I run Flutter run successfully, the basic App runs on the MyEm emulator.
I then open VSCode and at Line 43 there is an error
Invalid override.
The type of 'MyHomePage.createState' ('() → _MyHomePageState') isn't a subtype of 'StatefulWidget.createState' ('() → State<StatefulWidget>')
Can anyone help explain why this is happening?

I would better recommend you take a look on this link to create your first flutter app
and this link
I was having trouble to create my first app and it helped me to create my first flutter app.

Related

Dart_LoadScriptFromKernel: The binary program does not contain 'main'. when I run flutterfire configure

I've been looking for a solution to this problem and I can't find it anywhere.
I'm trying to install Firebase and every time I do the flutterfire configure command it pops up Dart_LoadScriptFromKernel: The binary program does not contain 'main'.
I've already done the flutter Clear command, flutter upgrade, installed and uninstalled the dart and flutter plugins. flutter doctor is ok.
I moved the project folder into other place.
Both in Android Studio and in VSCode I can run the app normally.
Thanks for help!

Flutter run never loads on vs code and sometimes crashes on android studio on my chromebook

I recently installed Flutter on my Chromebook (4 GB RAM). I have been writing snippets of dart code using vscode with no issues. Recently, I decided to move into the flutter framework, and then when I try to run the default application generated after creating a new project, VS Code freezes after a while. I know initially this was supposed to take a while to load being my first time, but is over 1 hour the appropriate time?
I have tried restarting VS Code several times, but still the same output. I even switched to using Android Studio, and this even crashes after a while.
What could be wrong or what am I getting wrong? I followed the official installation process on both VS Code and Flutter.dev sites.
i will assume that you have set up your emulator correctly and you opened the emulator with these steps:
1- on your keyboard use ctrl + shift + p and choose Flutter: Select Device and wait for the emulator to open.
2- after the emulator starts, from the upper menu of VSCode select Run > Run without debugging.
the app should run, if the problem persists, in VSCode open a new terminal window and type :
1- flutter upgrade
2- flutter clean
3- flutter pub get
try to run the application hopefully it will run

Flutter doesn't compile project after restart

My computer restarted for no reason and now all settings in flutter running in vs code have changed. During restart, I got an option to verify the author or something. I believe to hit trust but after that, I can't compile my project anymore plus the default behavior of the mouse buttons has changed. Right-click now shows, change all occurrences instead of default options. My phone is connected but it doesn't show up in the emulator/phone section below.
The same project runs fine in android studio
1st run flutter doctor to check if there any problem with install.
try to clean the project using flutter clean and rebuil/ run again.
Also you can run from terminal,
you can just type on terminal flutter run and it show devices then select one.
For emulators type flutter emulators , it will show your emulators,
to run on emulators flutter emulators --launch deviceName.
here the short form.
flutter clean
flutter pub get
flutter run
It worked after reinstalling all my extensions, primarily dart and flutter a couple of times. Thank you #amsakanna

Flutter on VS Code run stuck on "Installing build\app\outputs\apk\app.apk..."

When I run my application using the VS Code Run and Debug, The app is installed on my device and is stuck on a white screen. Meanwhile in the editor, the VS Code notification is stuck on "Installing build\app\outputs\apk\app.apk..."
I've tried to run different flutter apps on the physical device but was still met with the same error. I've also tried to run the flutter example increment app, but to no avail. I also uninstalled and reinstalled the flutter sdk from the stable GitHub branch but that also did not work. I've also tried solutions from about 22 other questions with similar problems.
However, when I use flutter run from the command line, the app installs and launches on my phone, however, I'm unable to use the Flutter DevTools Inspector.
P.S I've been able to debug flutter apps on the device with the Flutter DevTools in the past.
As of Flutter v1.20.2, this problem has been resolved. The linked GitHub issue is here if you disagree about the problem being solved.
You'll need to end the flutter, dart and flutter processes. So in terminal do this:
killall adb
killall dart
killall flutter
Then reload vscode

How to use the official Flutter gallery

Im totally new to flutter, and would like to try out the official examples gallery: https://github.com/flutter/flutter/tree/master/examples/flutter_gallery
I´ve installed Android studio and have the emulator running, which works great when i start the demo app from VS code.
Problem is, how do i fetch the gallery app, and load it onto the virtual device? The simple guide says I should run these two commands:
flutter packages get
flutter run --release
This does not work, as the terminal throws this error: "Release mode is not supported for emulators." If I instead run
flutter run --debug
it loads up the "You have pushed the button x this many times" standard demo app. And i really cant see how these two commands tells the terminal to get the flutter gallery.
I´ve also tried to change the flutter channel to dev, but this dosent help.
Flutter doctor says everything is OK.
So how do I you try out the official flutter gallery app?
You need to switch to the project directory of the gallery app first
cd your_flutter_install_dir/examples/flutter_gallery
flutter packages get
flutter run
If you have a real device connected (and the emulator closed) you can also use flutter run release