我正在使用 Flutter DIO 库。它在我的 Android 应用程序上运行良好,但在 Web 上出现错误。
Error: DioError [DioErrorType.response]: XMLHttpRequest error.
如果我尝试使用 http 相同的 url,它在 Web 上工作正常。我的 Dio 库代码
Dio dio = Dio();
dio.options.method = "POST";
dio.options.headers["Access-Control-Allow-Origin"] = "*";
dio.options.headers["Access-Control-Allow-Credentials"] = true;
dio.options.headers["Access-Control-Allow-Headers"] =
"Origin,Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,locale";
dio.options.headers["Access-Control-Allow-Methods"] =
"GET, HEAD, POST, OPTIONS";
var response = await dio
.post('http://45.79.124.182/app_php/PagarGuru_test/requestAdd.php');
Run Code Online (Sandbox Code Playgroud)
错误日志
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 908:28 get current
packages/dio/src/dio_mixin.dart 819:20 assureDioError
packages/dio/src/dio_mixin.dart 678:13 _dispatchRequest
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 60:31 <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1692:54 runBinary
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 175:22 handleError
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 779:46 handleError
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 800:13 _propagateToListeners
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 610:5 [_completeError]
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 666:7 …Run Code Online (Sandbox Code Playgroud) 我正在从 flutter 开发 IOS 应用程序。一切正常,突然我收到错误
SwiftCodeGeneration normal arm64 (in target 'DKImagePickerController' from project 'Pods')
cd /Users/lasthoney/development_project/flutter/workspace/CTRON/ios/Pods
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/lasthoney/Library/Developer/Xcode/DerivedData/Runner-ffimvuyezsoasahfibifkngbbnva/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/DKImagePickerController.build/Objects-normal/arm64/DKPopoverViewController.bc -embed-bitcode -target arm64-apple-ios9.0 -Xllvm -aarch64-use-tbi -O -disable-llvm-optzns -module-name DKImagePickerController -o /Users/lasthoney/Library/Developer/Xcode/DerivedData/Runner-ffimvuyezsoasahfibifkngbbnva/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/DKImagePickerController.build/Objects-normal/arm64/DKPopoverViewController.o
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/lasthoney/Library/Developer/Xcode/DerivedData/Runner-ffimvuyezsoasahfibifkngbbnva/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/DKImagePickerController.build/Objects-normal/arm64/DKPopoverViewController.bc -embed-bitcode -target arm64-apple-ios9.0 -Xllvm -aarch64-use-tbi -O -disable-llvm-optzns -module-name DKImagePickerController -o /Users/lasthoney/Library/Developer/Xcode/DerivedData/Runner-ffimvuyezsoasahfibifkngbbnva/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/DKImagePickerController.build/Objects-normal/arm64/DKPopoverViewController.o
1. Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)
2. Compiling with the current language …Run Code Online (Sandbox Code Playgroud)