【问题标题】:Flutter web - Unsupported operation: InternetAddress.LOOPBACK_IP_V4Flutter web - 不支持的操作:InternetAddress.LOOPBACK_IP_V4
【发布时间】:2020-08-02 21:42:38
【问题描述】:

我想试试 Flutter HttpServer 库,但一开始就卡住了。

import 'dart:io';

void main() async {
  var server = await HttpServer.bind(InternetAddress.loopbackIPv4, 8080);
}

继续以下异常:

Error: Unsupported operation: InternetAddress.LOOPBACK_IP_V4
    at Object.throw_ [as throw] (http://localhost:43203/dart_sdk.js:4040:11)
    at Function.get LOOPBACK_IP_V4 [as LOOPBACK_IP_V4] (http://localhost:43203/dart_sdk.js:59789:17)
    at Function.get loopbackIPv4 [as loopbackIPv4] (http://localhost:43203/dart_sdk.js:59786:33)
    at main (http://localhost:43203/packages/dolphin/main.dart.lib.js:13:68)
    at main.next (<anonymous>)
    at runBody (http://localhost:43203/dart_sdk.js:41692:34)
    at Object._async [as async] (http://localhost:43203/dart_sdk.js:41720:7)
    at Object.main$ [as main] (http://localhost:43203/packages/dolphin/main.dart.lib.js:12:18)
    at main$ (http://localhost:43203/web_entrypoint.dart.lib.js:14:12)
    at main$.next (<anonymous>)
    at onValue (http://localhost:43203/dart_sdk.js:41673:33)
    at _RootZone.runUnary (http://localhost:43203/dart_sdk.js:41558:58)
    at _FutureListener.thenAwait.handleValue (http://localhost:43203/dart_sdk.js:37044:29)
    at handleValueCallback (http://localhost:43203/dart_sdk.js:37545:49)
    at Function._propagateToListeners (http://localhost:43203/dart_sdk.js:37577:17)
    at async._AsyncCallbackEntry.new.callback (http://localhost:43203/dart_sdk.js:37333:27)
    at Object._microtaskLoop (http://localhost:43203/dart_sdk.js:41774:13)
    at _startMicrotaskLoop (http://localhost:43203/dart_sdk.js:41780:13)
    at http://localhost:43203/dart_sdk.js:37782:9

颤振版本:

Flutter 1.17.0 • channel beta • https://github.com/flutter/flutter.git
Framework • revision d3ed9ec945 (vor 2 Wochen) • 2020-04-06 14:07:34 -0700
Engine • revision c9506cb8e9
Tools • Dart 2.8.0 (build 2.8.0-dev.18.0 eea9717938)

操作系统:

  Operating System: Debian GNU/Linux 10 (buster)
            Kernel: Linux 4.19.0-8-amd64
      Architecture: x86-64

如果有人可以帮助我/知道我的错误是什么,那就太棒了。谢谢:)

【问题讨论】:

  • 我遇到了同样的问题,但只是向 Flutter 外部的本地 http 服务器发出基本请求。我猜flutter web不能使用httpserver。
  • 我也有类似的问题。当我启动时,DataConnectionChecker 会抛出该错误。奇怪的是,我可以实例化检查器和/或在测试中使用 get_it 检索它,它工作正常。很遗憾看到您的问题没有得到解决。 :-(

标签: flutter-web


【解决方案1】:
import 'dart:io';

flutter web.issue链接https://github.com/flutter/flutter/issues/39998不支持

【讨论】:

    【解决方案2】:
    1. 在您尝试修复的库中使用通用 IO:Pub.Dev Link

    2. 编写一个备份函数来替换为你中断的那个。查看这个 git commit 以获取选项。我必须替换 InternetAddress.lookup ,但您必须找出另一个支持 Web 的函数来替换 InternetAddress.LOOPBACK_IP_V4:Issue solved in a flutter project

    【讨论】:

      猜你喜欢
      • 2020-06-09
      • 2022-11-22
      • 2021-05-04
      • 2017-11-09
      • 1970-01-01
      • 1970-01-01
      • 2015-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多