@@ -850,24 +850,26 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
850850 }) {
851851 final protoBuilder = objc.ObjCProtocolBuilder ();
852852
853- ncb.NSURLSessionDataDelegate .addToBuilderAsListener (
854- protoBuilder,
855- URLSession_task_didCompleteWithError_ : (nsSession, nsTask, nsError) {
856- _decrementTaskCount ();
857- if (onComplete != null ) {
858- onComplete (
859- URLSession ._(nsSession,
860- isBackground: isBackground, hasDelegate: true ),
861- URLSessionTask ._(nsTask),
862- nsError);
863- }
864- },
865- );
853+ ncb.NSURLSessionDataDelegate .URLSession_task_didCompleteWithError_
854+ .implementAsListener (protoBuilder, (nsSession, nsTask, nsError) {
855+ _decrementTaskCount ();
856+ if (onComplete != null ) {
857+ onComplete (
858+ URLSession ._(nsSession,
859+ isBackground: isBackground, hasDelegate: true ),
860+ URLSessionTask ._(nsTask),
861+ nsError);
862+ }
863+ });
866864
867865 if (onRedirect != null ) {
868- ncb.NSURLSessionDataDelegate .addToBuilderAsListener (protoBuilder,
866+ ncb
867+ .NSURLSessionDataDelegate
869868 // ignore: lines_longer_than_80_chars
870- URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_ :
869+ .URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler_
870+ .implementAsListener (protoBuilder,
871+ // ignore: lines_longer_than_80_chars
872+
871873 (nsSession, nsTask, nsResponse, nsRequest, nsRequestCompleter) {
872874 final request = URLRequest ._(nsRequest);
873875 URLRequest ? redirectRequest;
@@ -891,8 +893,9 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
891893 }
892894
893895 if (onResponse != null ) {
894- ncb.NSURLSessionDataDelegate .addToBuilderAsListener (protoBuilder,
895- URLSession_dataTask_didReceiveResponse_completionHandler_ :
896+ ncb.NSURLSessionDataDelegate
897+ .URLSession_dataTask_didReceiveResponse_completionHandler_
898+ .implementAsListener (protoBuilder,
896899 (nsSession, nsDataTask, nsResponse, nsCompletionHandler) {
897900 final exactResponse = URLResponse ._exactURLResponseType (nsResponse);
898901 final disposition = onResponse (
@@ -905,8 +908,8 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
905908 }
906909
907910 if (onData != null ) {
908- ncb.NSURLSessionDataDelegate .addToBuilderAsListener (protoBuilder,
909- URLSession_dataTask_didReceiveData_ : (nsSession, nsDataTask, nsData) {
911+ ncb.NSURLSessionDataDelegate .URLSession_dataTask_didReceiveData_
912+ . implementAsListener (protoBuilder, (nsSession, nsDataTask, nsData) {
910913 onData (
911914 URLSession ._(nsSession,
912915 isBackground: isBackground, hasDelegate: true ),
@@ -942,9 +945,9 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
942945 }
943946
944947 if (onWebSocketTaskOpened != null ) {
945- ncb.NSURLSessionWebSocketDelegate . addToBuilderAsListener (protoBuilder,
946- URLSession_webSocketTask_didOpenWithProtocol_ :
947- (nsSession, nsTask, nsProtocol) {
948+ ncb.NSURLSessionWebSocketDelegate
949+ . URLSession_webSocketTask_didOpenWithProtocol_
950+ . implementAsListener (protoBuilder, (nsSession, nsTask, nsProtocol) {
948951 onWebSocketTaskOpened (
949952 URLSession ._(nsSession,
950953 isBackground: isBackground, hasDelegate: true ),
@@ -954,8 +957,9 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
954957 }
955958
956959 if (onWebSocketTaskClosed != null ) {
957- ncb.NSURLSessionWebSocketDelegate .addToBuilderAsListener (protoBuilder,
958- URLSession_webSocketTask_didCloseWithCode_reason_ :
960+ ncb.NSURLSessionWebSocketDelegate
961+ .URLSession_webSocketTask_didCloseWithCode_reason_
962+ .implementAsListener (protoBuilder,
959963 (nsSession, nsTask, closeCode, reason) {
960964 onWebSocketTaskClosed (
961965 URLSession ._(nsSession,
0 commit comments