简体   繁体   中英

Flutter install error, "Bad state: Future already completed"

I am trying to install Flutter on Mac but I am getting an error, "Bad state: Future already completed". Below is my output of "flutter doctor -v" Any ideas what I should try on how to troubleshoot this?

MacBook-Pro:~$ flutter doctor -v
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.1 18B75, locale en-CN)
    • Flutter version 1.0.0 at /Users/tortilla/dev/programs/flutter
    • Framework revision 5391447fae (3 weeks ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

⣾Unhandled exception:
Bad state: Future already completed
#0      _AsyncCompleter.complete (dart:async/future_impl.dart:39:31)
#1      _NativeSocket.startConnect.<anonymous closure>.connectNext.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:490:23)
#2      _NativeSocket.issueWriteEvent.issue (dart:io/runtime/binsocket_patch.dart:844:14)
#3      _NativeSocket.issueWriteEvent (dart:io/runtime/binsocket_patch.dart:851:12)
#4      _NativeSocket.multiplex (dart:io/runtime/binsocket_patch.dart:872:11)
#5      _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)

As mentioned in this Flutter issue you can run flutter config --no-analytics to disable requests to google analytics. I had to restart the terminal after doing this. Commands such as flutter doctor then seemed to work.

However, if you still receive issues with flutter build or flutter pub get this is probably due to a bug in the Dart Pub library mentioned in this Dart issue . The problem lies with some network requests that dart pub get seems to make.

On my Mac, the problem was triggered by Avast seeming to block these requests. Replacing Avast with another AV and using the Mac's built-in Firewall seemed to workaround this issue. This is perhaps a temporary workaround at best as changing your AV program is an extreme solution.

This is likely a firewall issue

If you are in China see https://flutter.io/community/china

If you are using a self-signed certificate see https://github.com/flutter/flutter/issues/15014

In my case (China), using a local mirror according to the instruction in Zöchbauer's answer was not enough.

While running flutter doctor , I had to turn on a VPN (I use Astrill) and switch to StealthVPN mode to fix this.

Refer to this github issue and jump to ScholarChild's comment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM