webview连接到0.0.0.0,加载js代码

Android项目有个flutter做的sdk,其中用到了webview用于执行js,

//webViewRunner.dart

...

    _web.launch(
      'https://localhost:8080/',
      clearCookies: true,
      clearCache: true,
      javascriptChannels: [
        JavascriptChannel(
            name: 'PolkaWallet',
            onMessageReceived: (JavascriptMessage message) {
              print('received msg: ${message.message}');
              compute(jsonDecode, message.message).then((msg) {
                final String path = msg['path'];
                if (_msgCompleters[path] != null) {
                  Completer handler = _msgCompleters[path];
                  handler.complete(msg['data']);
                  if (path.contains('uid=')) {
                    _msgCompleters.remove(path);
                  }
                }
                if (_msgHandlers[path] != null) {
                  Function handler = _msgHandlers[path];
                  handler(msg['data']);
                }
              });
            }),
      ].toSet(),
      ignoreSSLErrors: true,
      // withLocalUrl: true,
      hidden: true,
    );

...

sdk初始化时会启动webview访问本机0.0.0.0的8080端口,加载项目目录下的js代码,Log输出:

E/flutter (22267): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: SocketException: Failed to create server socket (OS Error: Address already in use, errno = 98), address = 0.0.0.0, port = 8080
E/flutter (22267): #0      _NativeSocket.bind (dart:io-patch/socket_patch.dart:945:7)
E/flutter (22267): <asynchronous suspension>
E/flutter (22267): #1      _RawServerSocket.bind.> (dart:io-patch/socket_patch.dart)
E/flutter (22267): <asynchronous suspension>

但是为什么要建了一个socket连接到本地0.0.0.0的8080端口进行加载项目目录下的js,而不是直接本地加载?加载的js代码并不是在网络上的,新建个socket不是多此一举吗?

你可能感兴趣的:(Android,Flutter)