Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter taking an unexpectedly long time for connecting to browser

Tags:

flutter

dart

I'm building flutter web project and after implenting login page via firebase I ran flutter run -d chrome. But it's stuck while attempting to connect to browser, its just attempting for endless time without giving any error messages. Status bar:

λ flutter run -d chrome
Launching lib\main.dart on Chrome in debug mode...
Building application for the web...                                20,2s
Attempting to connect to browser instance..                             
(This is taking an unexpectedly long time.)       \

Flutter doctor:

λ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, v1.10.11-pre.2, on Microsoft Windows [Version 10.0.18362.356], locale ru-RU)
[X] Android toolchain - develop for Android devices
    X Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
      You may also want to add it to your PATH environment variable.

[√] Chrome - develop for the web
[!] Android Studio (not installed)
[√] VS Code (version 1.38.1)
[√] Connected device (2 available)

! Doctor found issues in 2 categories.

pubspec.yaml:

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  firebase: ^5.0.0
  firebase_auth: 
like image 651
Massaget Avatar asked Oct 04 '19 14:10

Massaget


People also ask

Why flutter run taking too long?

When flutter run is taking forever to initialize gradle it is probably due to network problem. Else, you might need to download gradle manually and install it. Downloading gradle manually is advisable especially if you are connected to extremely slow network.

Why does the first flutter app build take so long?

When you are going to build the Flutter app for the first time, it takes a very long time than usual because Flutter builds a device-specific IPA or APK file. In this process, the Xcode and Gradle are used to build a file, which usually takes a long time.

Can Chrome run flutter?

If Chrome is installed, the flutter devices command outputs a Chrome device that opens the Chrome browser with your app running, and a Web Server that provides the URL serving the app. In your IDE, you should see Chrome (web) in the device pulldown.

Does flutter run faster on Android Studio?

So, it will take time. After the first build, as and when, new dependencies are added, the run time may increase. But after the first build, it runs faster. Man i have been working with Flutter on Android Studio for a year now,and it works fine.And my pc has 8GB ram, 1 TB of HDD and powered with Ryzen5.

Can flutter be used for web development?

In addition to mobile applications Flutter has introduced web support, which generates web content rendered using the standard web technology stack: HTML, CSS, and JavaScript. This way, you can compile existing Flutter code written in Dart into a web project that can be embedded in the browser and deployed to any web server.

How to check if flutter is working or not?

You can check which branch of flutter you are using, run from the command line (with verbose option) to check if any errors are being reported. Please give some more context, have you added any files to your project, or it might be the speed of your computer. Please provide more context. Also, try running flutter doctor in your cmd/termianl

Can I compile existing flutter code written in dart into a project?

This way, you can compile existing Flutter code written in Dart into a web project that can be embedded in the browser and deployed to any web server.


Video Answer


3 Answers

Try with flutter run -d web-server, then open URL on Chrome manually.

like image 132
Giampaolo Avatar answered Sep 18 '22 05:09

Giampaolo


  1. Remove all unused dependencies
  2. flutter run -d web-server

The answer mentioned by @Giampaolo is a great workaround!

like image 34
Shashwat Aditya Avatar answered Sep 17 '22 05:09

Shashwat Aditya


Same issue here. When trying the sample project, it works. I think the problem has something to do with dependencies, but have not figured out in detail.

Update: Could be related: https://github.com/flutter/flutter/issues/40876 and https://github.com/flutter/flutter/issues/39998

Update #2: I could reproduce the issue a described in https://github.com/flutter/flutter/issues/39998

1) Create fresh flutter project with web support -> works.

2) add import 'dart:io'; to main.dart -> blank screen

like image 43
x23b5 Avatar answered Sep 20 '22 05:09

x23b5