Since flutter 1.9 : how to run flutter app in a browser ? Flutter run -d chrome not working
Asked Answered
R

11

49

Since flutter 1.9 flutter_web is merged inside flutter. I'm trying to run the initial flutter app in a chrome browser but it fails. OS is ubuntu 19.04

The command I used with success: flutter upgrade

flutter create test_1_9

cd test_1_9

flutter run

The command not working:

flutter run -d chrome

=> No devices found with name or id matching 'chrome'

I tried with google-chrome as device name with same result

[✓] Flutter (Channel master, v1.10.2-pre.38, on Linux, locale fr_FR.UTF-8)
    • Flutter version 1.10.2-pre.38 at /home/rbarbe/programes/flutter
    • Framework revision e6ae95c4ce (il y a 18 heures), 2019-09-11 07:46:57 -0700
    • Engine revision 7ea9884ab0
    • Dart version 2.5.0 (build 2.5.0-dev.4.0 be66176534)


[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /home/rbarbe/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /home/rbarbe/programes/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[✓] Android Studio (version 3.3)
    • Android Studio at /home/rbarbe/programes/android-studio
    • Flutter plugin version 33.3.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[✓] IntelliJ IDEA Community Edition (version 2019.1)
    • IntelliJ at /home/rbarbe/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/191.6183.87
    • Flutter plugin version 35.2.2
    • Dart plugin version 191.6183.88

[✓] IntelliJ IDEA Community Edition (version 2019.2)
    • IntelliJ at /home/rbarbe/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/192.6603.28
    • Flutter plugin version 39.0.5
    • Dart plugin version 192.6603.23

[✓] VS Code (version 1.38.0)
    • VS Code at /usr/share/code
    • Flutter extension version 3.4.1

[✓] Connected device (1 available)
    • CLT L29 • WCR0218315003400 • android-arm64 • Android 9 (API 28)

• No issues found!
Radiate answered 12/9, 2019 at 9:2 Comment(2)
I have followed this steps and it's working! flutter.dev/docs/get-started/webCessation
You're right @SharadPaghadal, documentation has bee updated since this morning. I didn't know about the following command : flutter config --enable-webRadiate
C
45

Have you enabled web support by flutter config --enable-web ?

enter image description here

Got Reference from this link

Cessation answered 12/9, 2019 at 9:52 Comment(4)
Even after running flutter config --enable-web still m getting error as No devices found with name or id matching 'chrome'.Expendable
which channel you are on? Please update the flutter once flutter upgradeCessation
@DhavalKansara Make sure you are on stable channelCessation
It was not working on the stable channel. After I took check out for the master branch I'll found chrome in flutter devices.Expendable
C
33

For these people whose chrome still cannot be detected even after flutter config --enable-web.You should check if your flutter in appropriate branch ,to list all branches, use:

flutter channel

output may looks like this:

Flutter channels:  
   beta  
   dev  
   master  
*  stable 

item with asterisk prefix indicates which branch you are in.To switch to master, try:

flutter channel master

after that, your flutter doctor can list chromedevice.

Check answered 24/9, 2019 at 1:56 Comment(1)
fantastic, i was searching solution for 2 hours before reaching this out. 100% works!Weswesa
D
26

https://flutter.dev/docs/get-started/web

$ flutter channel master
$ flutter upgrade
$ flutter config --enable-web

$ flutter devices  //downloads sky_engine and sdk tools then shows a list of devices including chrome

$ flutter create test_app
$ flutter run -d chrome  //local host will run chrome


>>>>>>>Extras

if you need run in optimized mode and disable security than

flutter run -d chrome --web-renderer html --web-browser-flag  "--disable-web-security" 

to compile your code for chrome deployment use

flutter build web --release --web-renderer=html
Drove answered 18/2, 2020 at 11:21 Comment(4)
in visual studio code for windows 10, select the main.dart file it will give you a run icon on the top right side, letting you run with debug.Drove
These steps worked for me only that instead of flutter run -d chrome, I used flutter run -d linux for the obvious reason --Linux.Assured
flutter run -d chrome did the magicTicktack
flutter run -d chrome --release --dart-define=FLUTTER_WEB_USE_SKIA=true --dart-define=FLUTTER_WEB_COMPRESSED=true (this commands runs the code like you will see when released to production)Drove
W
13
flutter run -d chrome --web-renderer html
Waylan answered 2/10, 2021 at 9:28 Comment(1)
Thanks, bro. This works in ubuntu 21.10.Pomade
M
5

In my case - flutter doctor gave me the following output

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

as on arch, the binary is called google-chrome-stable and/or google-chrome-unstable

export CHROME_EXECUTABLE=/usr/bin/google-chrome-stable

was all that was needed to get it working.

Marcy answered 5/9, 2020 at 22:45 Comment(2)
To add to this, all available environment variables are declared here : github.com/flutter/flutter/blob/master/packages/flutter_tools/…. Right now, they are CHROME_EXECUTABLE and EDGE_ENVIRONMENT.Butadiene
This is really helpful! Thanks!Maus
S
0

You need to run a server for web and will then be available at a port presumably 8080. If everything is set up correctly you can just:

webdev serve

otherwise try:

   flutter packages pub global run webdev serve
Sewing answered 12/9, 2019 at 9:15 Comment(1)
that was prior to 1.9 release, it's now deprecatedRadiate
G
0

Also make sure to upgrade flutter form the master instead of the stable branch

Granddaddy answered 13/9, 2019 at 12:26 Comment(0)
D
0

For Ubuntu, ensure you are on the master channel by running

flutter channel master

Then run

flutter upgrade

Allow HTML web rendering be running

flutter run -d chrome --web-renderer html

Dappled answered 6/3, 2022 at 14:56 Comment(0)
H
0

Adding chrome to user variables worked for me, I moved chrome to another drive and it was not being identified by flutter.

System properties > Environmental Variables > on user, create new then add:

Variable name :CHROME_EXECUTABLE

Variable Value :D:\Program Files\Google\Chrome\Application\chrome.exe (location of your chrome.exe file)

Hyperparathyroidism answered 9/1 at 6:17 Comment(0)
A
-2

If you are trying to develop web Application with dart then my suggestion is to create new Dart Project -> Angular Dart -> After successfully created angular dart -> then open terminal -> type "Webdev serve"

Arius answered 26/9, 2019 at 7:1 Comment(0)
L
-3

you need cd to your flutter install workspace, and run:

git checkout master
Lieu answered 18/9, 2019 at 10:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.