Flutter花费了很长时间才能连接到浏览器


9

我正在构建flutter Web项目,并通过firebase使登录页面生效后,我运行了flutter run -d chrome。但是它在尝试连接浏览器时被卡住了,它只是尝试了无休止的时间而没有给出任何错误消息。状态栏:

λ 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
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: 

就我而言,那是因为我已经感动lib/main.dartlib/main.web.dart。即使使用flutter run -d chrome -t ./lib/main.web.dart,该应用也可以正确构建,但随后颤动将无法连接到浏览器
Gpack

我遇到了同样的问题,因为我忘了添加主要功能void main() => runApp(MyApp());
maheshmnj

Answers:




1

同样的问题。它无法获取浏览器的实例。

我尝试删除未使用的导入,在我的情况下为“ import'dart:ffi';”。这是未使用的导入和数据处理。

我只是不知道到底是什么问题。


1

尝试使用flutter run -d web-server,然后在Chrome上手动打开URL。


为什么不?显然,这是一种解决方法
Giampaolo
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.