Home > database >  Why is HTTP Request on Flutter for MacOS desktop not working on Release?
Why is HTTP Request on Flutter for MacOS desktop not working on Release?

Time:01-05

I'm making a HTTP is debug or profile build, and it works fine. But if I switch to Release it no longer works

 [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)

I assume it's Internet permissions issue, but I can't find where I need to add permission (info.plist?) and what permissions I need to add?

[✓] 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

CodePudding user response:

Check this MacOS flutter documentation.

Add the below lines in the macos/Runner/DebugProfile.entitlements and macos/Runner/Release.entitlements:

<key>com.apple.security.network.client</key>
<true/>
  •  Tags:  
  • Related