Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change default build target from flutter for web to flutter for Android

Tags:

flutter

I am using VS Code. After some experiments with building flutter for web it's began to build every project for web be default. I need to get it back by default Android version.

PS D:\code\2019\dart_app1\app1> flutter devices
2 connected devices:
Windows • Windows • windows-x64    • Microsoft Windows [Version 10.0.17134.984]
Chrome  • chrome  • web-javascript • Google Chrome 76.0.3809.132
>PS D:\code\2019\dart_app1\app1> flutter emulators
3 available emulators:
Nexus_5X_API_29  • Nexus 5X API 29  • Google • android
Nexus_9_API_28   • Nexus 9 API 28   • Google • android
flutter_emulator • flutter emulator • Google • android
To run an emulator, run 'flutter emulators --launch <emulator id>'.
To create a new emulator, run 'flutter emulators --create [--name xyz]'.
You can find more information on managing emulators at the links below:
  https://developer.android.com/studio/run/managing-avds
  https://developer.android.com/studio/command-line/avdmanager

launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Flutter",
            "request": "launch",
            "type": "dart"
        }
    ]
}
like image 851
Dmitry Bubnenkov Avatar asked Sep 11 '19 09:09

Dmitry Bubnenkov


People also ask

Can you use Flutter to build web app?

Flutter is an ideal choice for businesses looking to develop an app for the web and mobile at the same time. With Flutter, a single codebase can be used to develop apps for different platforms.


1 Answers

Specify your device in launch.json file with args parameter:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Flutter",
            "request": "launch",
            "type": "dart",
            "args": ["-d", "<device name from adb devices output>"]
        }
    ]
}

Or select from vscode bottom panel at right side. By default launcher select first available device, and chrome device probably always that.

like image 84
Spatz Avatar answered Oct 26 '22 12:10

Spatz