skip to Main Content

I wanted to try out the flutter HttpServer library but stucked a the very beginning.

import 'dart:io';

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

proceed the following exception:

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

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)

OS:

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

Would be awesome if someone can help me out / has an idea whats my mistake. Thanks 🙂

2

Answers


  1. import 'dart:io';
    

    is not supported by flutter web.issue link https://github.com/flutter/flutter/issues/39998

    Login or Signup to reply.
    1. Use Universal IO in the library you are trying to fix: Pub.Dev Link

    2. Write a backup function to replace the one that breaks for you. Check out this git commit, for options. I had to replace InternetAddress.lookup , but you have to figure out another web supported function to replace InternetAddress.LOOPBACK_IP_V4: Issue solved in a flutter project

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search