diff --git a/pkgs/cupertino_http/CHANGELOG.md b/pkgs/cupertino_http/CHANGELOG.md index 616e07b6cb..d0d5124631 100644 --- a/pkgs/cupertino_http/CHANGELOG.md +++ b/pkgs/cupertino_http/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.0.1-wip + +* Fix a [bug](https://github.com/dart-lang/http/issues/1398) where + `package:cupertino_http` only worked with iOS 17+. + ## 2.0.0 * The behavior of `CupertinoClient` and `CupertinoWebSocket` has not changed. diff --git a/pkgs/cupertino_http/lib/src/cupertino_api.dart b/pkgs/cupertino_http/lib/src/cupertino_api.dart index 99fb2ee041..2be208f308 100644 --- a/pkgs/cupertino_http/lib/src/cupertino_api.dart +++ b/pkgs/cupertino_http/lib/src/cupertino_api.dart @@ -850,24 +850,26 @@ class URLSession extends _ObjectHolder { }) { final protoBuilder = objc.ObjCProtocolBuilder(); - ncb.NSURLSessionDataDelegate.addToBuilderAsListener( - protoBuilder, - URLSession_task_didCompleteWithError_: (nsSession, nsTask, nsError) { - _decrementTaskCount(); - if (onComplete != null) { - onComplete( - URLSession._(nsSession, - isBackground: isBackground, hasDelegate: true), - URLSessionTask._(nsTask), - nsError); - } - }, - ); + ncb.NSURLSessionDataDelegate.URLSession_task_didCompleteWithError_ + .implementAsListener(protoBuilder, (nsSession, nsTask, nsError) { + _decrementTaskCount(); + if (onComplete != null) { + onComplete( + URLSession._(nsSession, + isBackground: isBackground, hasDelegate: true), + URLSessionTask._(nsTask), + nsError); + } + }); if (onRedirect != null) { - ncb.NSURLSessionDataDelegate.addToBuilderAsListener(protoBuilder, + ncb + .NSURLSessionDataDelegate // ignore: lines_longer_than_80_chars - URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_: + .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_ + .implementAsListener(protoBuilder, + // ignore: lines_longer_than_80_chars + (nsSession, nsTask, nsResponse, nsRequest, nsRequestCompleter) { final request = URLRequest._(nsRequest); URLRequest? redirectRequest; @@ -891,8 +893,9 @@ class URLSession extends _ObjectHolder { } if (onResponse != null) { - ncb.NSURLSessionDataDelegate.addToBuilderAsListener(protoBuilder, - URLSession_dataTask_didReceiveResponse_completionHandler_: + ncb.NSURLSessionDataDelegate + .URLSession_dataTask_didReceiveResponse_completionHandler_ + .implementAsListener(protoBuilder, (nsSession, nsDataTask, nsResponse, nsCompletionHandler) { final exactResponse = URLResponse._exactURLResponseType(nsResponse); final disposition = onResponse( @@ -905,8 +908,8 @@ class URLSession extends _ObjectHolder { } if (onData != null) { - ncb.NSURLSessionDataDelegate.addToBuilderAsListener(protoBuilder, - URLSession_dataTask_didReceiveData_: (nsSession, nsDataTask, nsData) { + ncb.NSURLSessionDataDelegate.URLSession_dataTask_didReceiveData_ + .implementAsListener(protoBuilder, (nsSession, nsDataTask, nsData) { onData( URLSession._(nsSession, isBackground: isBackground, hasDelegate: true), @@ -942,9 +945,9 @@ class URLSession extends _ObjectHolder { } if (onWebSocketTaskOpened != null) { - ncb.NSURLSessionWebSocketDelegate.addToBuilderAsListener(protoBuilder, - URLSession_webSocketTask_didOpenWithProtocol_: - (nsSession, nsTask, nsProtocol) { + ncb.NSURLSessionWebSocketDelegate + .URLSession_webSocketTask_didOpenWithProtocol_ + .implementAsListener(protoBuilder, (nsSession, nsTask, nsProtocol) { onWebSocketTaskOpened( URLSession._(nsSession, isBackground: isBackground, hasDelegate: true), @@ -954,8 +957,9 @@ class URLSession extends _ObjectHolder { } if (onWebSocketTaskClosed != null) { - ncb.NSURLSessionWebSocketDelegate.addToBuilderAsListener(protoBuilder, - URLSession_webSocketTask_didCloseWithCode_reason_: + ncb.NSURLSessionWebSocketDelegate + .URLSession_webSocketTask_didCloseWithCode_reason_ + .implementAsListener(protoBuilder, (nsSession, nsTask, closeCode, reason) { onWebSocketTaskClosed( URLSession._(nsSession, diff --git a/pkgs/cupertino_http/pubspec.yaml b/pkgs/cupertino_http/pubspec.yaml index 8a442de791..94ceb6bdff 100644 --- a/pkgs/cupertino_http/pubspec.yaml +++ b/pkgs/cupertino_http/pubspec.yaml @@ -1,5 +1,5 @@ name: cupertino_http -version: 2.0.0 +version: 2.0.1-wip description: >- A macOS/iOS Flutter plugin that provides access to the Foundation URL Loading System.