【问题标题】:Why is HTTP Request on Flutter for MacOS desktop not working on Release?为什么 Flutter for MacOS 桌面上的 HTTP 请求在 Release 上不起作用?
【发布时间】:2022-01-04 18:19:37
【问题描述】:

我正在制作一个 HTTP 是调试或配置文件构建,它工作正常。但是如果我切换到 Release 它就不再起作用了

 [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: Failed host lookup: '*******.*******.*****.io' (OS Error: nodename nor servname provided, or not known, errno = 8)
#0      _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:681)
#1      _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1808)
#2      RawSocket.startConnect (dart:io-patch/socket_patch.dart:27)
#3      RawSecureSocket.startConnect (dart:io/secure_socket.dart:237)
#4      SecureSocket.startConnect (dart:io/secure_socket.dart:60)
#5      _ConnectionTarget.connect (dart:_http/http_impl.dart:2437)
#6      _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2808)
#7      _HttpClient._getConnection (dart:_http/http_impl.dart:2813)

我认为是 Internet 权限问题,但我找不到需要添加权限的位置(info.plist?)以及需要添加哪些权限?

[✓] Connected device (3 available)
    • iPad Pro (12.9-inch) (5th generation) (mobile) • 00008103-000E44D10C3B001E • ios            • iOS 15.1 19B74
    • macOS (desktop)                                • macos                     • darwin-arm64   • macOS 12.0.1 21A559 darwin-arm
    • Chrome (web)                                   • chrome                    • web-javascript • Google Chrome 96.0.4664.110

【问题讨论】:

    标签: xcode flutter macos android-studio http


    【解决方案1】:

    查看thisMacOS Flutter 文档。

    macos/Runner/DebugProfile.entitlementsmacos/Runner/Release.entitlements 中添加以下行:

    <key>com.apple.security.network.client</key>
    <true/>
    

    【讨论】:

      猜你喜欢
      • 2020-11-15
      • 2021-02-16
      • 2015-04-11
      • 2022-06-13
      • 1970-01-01
      • 2020-09-19
      • 2018-09-20
      • 1970-01-01
      • 2014-03-31
      相关资源
      最近更新 更多