在WEB中运行Flutter:错误:XMLHttpRequest错误



我在Flutter中构建了一个应用程序,它可以完美地作为Android应用程序运行,但当我试图在Chrome中运行相同的应用程序时,我收到了以下错误。正如你在错误中看到的那样,我没有引用我的代码,只是为了";dart-sdk/lib";。

我该如何解决这个问题?

****错误消息***

Launching libmain.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
Debug service listening on ws://127.0.0.1:52742/ewRwL069luw=/ws
Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
Debug service listening on ws://127.0.0.1:52742/ewRwL069luw=/ws
Error: XMLHttpRequest error.
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 906:28                get current
packages/http/src/browser_client.dart 84:22                                                                                    <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1446:54                                              runUnary
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 150:18                                        handleValue
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 703:44                                        handleValueCallback
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 732:32                                        _propagateToListeners
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 526:7                                         [_complete]
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream_pipe.dart 61:11                                         _cancelAndValue
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream.dart 1302:7                                             <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 324:14  _checkAndCall
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 329:39  dcall
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/html/dart2js/html_dart2js.dart 37312:58                              <fn>

at Object.createErrorWithStack (http://localhost:52678/dart_sdk.js:4368:12)
at Object._rethrow (http://localhost:52678/dart_sdk.js:38289:16)
at async._AsyncCallbackEntry.new.callback (http://localhost:52678/dart_sdk.js:38283:13)
at Object._microtaskLoop (http://localhost:52678/dart_sdk.js:38115:13)
at _startMicrotaskLoop (http://localhost:52678/dart_sdk.js:38121:13)
at http://localhost:52678/dart_sdk.js:33618:9

您是否正在进行网络请求?

如果是这样,您需要更改后端的CORS策略以允许这样做。

在此处查看

相关内容

  • 没有找到相关文章

最新更新