diff --git a/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md b/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md index f5a9fd6ef336..c1f364b98bd7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md +++ b/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md @@ -1,3 +1,9 @@ +## 3.27.0 + +* Adds support for loading resources with custom URL schemes via + `WebKitWebViewControllerCreationParams.urlSchemeHandlers`, backed by the + native `WKURLSchemeHandler` API. + ## 3.26.0 * Adds new method for accessing a native `WKWebView` from a `FlutterPluginRegistrar`. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/ErrorProxyAPITests.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/ErrorProxyAPITests.swift index dc0af4c1c5fc..dcd467a15a47 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/ErrorProxyAPITests.swift +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/ErrorProxyAPITests.swift @@ -7,6 +7,19 @@ import XCTest @testable import webview_flutter_wkwebview class ErrorProxyAPITests: XCTestCase { + func testPigeonDefaultConstructor() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiNSError(registrar) + + let instance = try? api.pigeonDelegate.pigeonDefaultConstructor( + pigeonApi: api, code: 42, domain: "domain", + userInfo: [NSLocalizedDescriptionKey: "description"]) + + XCTAssertEqual(instance?.code, 42) + XCTAssertEqual(instance?.domain, "domain") + XCTAssertEqual(instance?.localizedDescription, "description") + } + func testCode() { let registrar = TestProxyApiRegistrar() let api = registrar.apiDelegate.pigeonApiNSError(registrar) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/HTTPURLResponseProxyAPITests.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/HTTPURLResponseProxyAPITests.swift index c6d71551848a..4c28f6eda4f6 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/HTTPURLResponseProxyAPITests.swift +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/HTTPURLResponseProxyAPITests.swift @@ -7,6 +7,28 @@ import XCTest @testable import webview_flutter_wkwebview class HTTPURLResponseProxyAPITests: XCTestCase { + func testPigeonDefaultConstructor() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiHTTPURLResponse(registrar) + + let instance = try? api.pigeonDelegate.pigeonDefaultConstructor( + pigeonApi: api, statusCode: 404, url: "http://google.com", httpVersion: nil, + headerFields: ["Content-Type": "image/png"]) + + XCTAssertEqual(instance?.url, URL(string: "http://google.com")) + XCTAssertEqual(instance?.statusCode, 404) + XCTAssertEqual(instance?.value(forHTTPHeaderField: "Content-Type"), "image/png") + } + + func testPigeonDefaultConstructorWithInvalidUrl() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiHTTPURLResponse(registrar) + + XCTAssertThrowsError( + try api.pigeonDelegate.pigeonDefaultConstructor( + pigeonApi: api, statusCode: 200, url: "", httpVersion: nil, headerFields: nil)) + } + func testStatusCode() { let registrar = TestProxyApiRegistrar() let api = registrar.apiDelegate.pigeonApiHTTPURLResponse(registrar) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/URLResponseProxyAPITests.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/URLResponseProxyAPITests.swift new file mode 100644 index 000000000000..475ac1d737cd --- /dev/null +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/URLResponseProxyAPITests.swift @@ -0,0 +1,33 @@ +// Copyright 2013 The Flutter Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import XCTest + +@testable import webview_flutter_wkwebview + +class URLResponseProxyAPITests: XCTestCase { + func testPigeonDefaultConstructor() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiURLResponse(registrar) + + let instance = try? api.pigeonDelegate.pigeonDefaultConstructor( + pigeonApi: api, url: "test-scheme://host/resource", mimeType: "image/png", + expectedContentLength: 3, textEncodingName: nil) + + XCTAssertEqual(instance?.url, URL(string: "test-scheme://host/resource")) + XCTAssertEqual(instance?.mimeType, "image/png") + XCTAssertEqual(instance?.expectedContentLength, 3) + XCTAssertNil(instance?.textEncodingName) + } + + func testPigeonDefaultConstructorWithInvalidUrl() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiURLResponse(registrar) + + XCTAssertThrowsError( + try api.pigeonDelegate.pigeonDefaultConstructor( + pigeonApi: api, url: "", mimeType: nil, expectedContentLength: 0, + textEncodingName: nil)) + } +} diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/URLSchemeHandlerProxyAPITests.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/URLSchemeHandlerProxyAPITests.swift new file mode 100644 index 000000000000..5cfb686c2e82 --- /dev/null +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/URLSchemeHandlerProxyAPITests.swift @@ -0,0 +1,90 @@ +// Copyright 2013 The Flutter Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import WebKit +import XCTest + +@testable import webview_flutter_wkwebview + +class URLSchemeHandlerProxyAPITests: XCTestCase { + func testPigeonDefaultConstructor() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiWKURLSchemeHandler(registrar) + + let instance = try? api.pigeonDelegate.pigeonDefaultConstructor(pigeonApi: api) + XCTAssertNotNil(instance) + } + + @MainActor func testStartUrlSchemeTask() { + let api = TestURLSchemeHandlerApi() + let registrar = TestProxyApiRegistrar() + let instance = URLSchemeHandlerImpl(api: api, registrar: registrar) + let webView = WKWebView() + let task = TestURLSchemeTask() + + instance.webView(webView, start: task) + + XCTAssertEqual(api.startUrlSchemeTaskArgs, [webView, task]) + XCTAssertFalse(URLSchemeTaskState.isStopped(task)) + } + + @MainActor func testStopUrlSchemeTask() { + let api = TestURLSchemeHandlerApi() + let registrar = TestProxyApiRegistrar() + let instance = URLSchemeHandlerImpl(api: api, registrar: registrar) + let webView = WKWebView() + let task = TestURLSchemeTask() + + instance.webView(webView, stop: task) + + XCTAssertEqual(api.stopUrlSchemeTaskArgs, [webView, task]) + XCTAssertTrue(URLSchemeTaskState.isStopped(task)) + } +} + +class TestURLSchemeHandlerApi: PigeonApiProtocolWKURLSchemeHandler { + var startUrlSchemeTaskArgs: [AnyHashable?]? = nil + var stopUrlSchemeTaskArgs: [AnyHashable?]? = nil + + func startUrlSchemeTask( + pigeonInstance pigeonInstanceArg: WKURLSchemeHandler, webView webViewArg: WKWebView, + urlSchemeTask urlSchemeTaskArg: WKURLSchemeTask, + completion: @escaping (Result) -> Void + ) { + startUrlSchemeTaskArgs = [webViewArg, urlSchemeTaskArg as? NSObject] + } + + func stopUrlSchemeTask( + pigeonInstance pigeonInstanceArg: WKURLSchemeHandler, webView webViewArg: WKWebView, + urlSchemeTask urlSchemeTaskArg: WKURLSchemeTask, + completion: @escaping (Result) -> Void + ) { + stopUrlSchemeTaskArgs = [webViewArg, urlSchemeTaskArg as? NSObject] + } +} + +class TestURLSchemeTask: NSObject, WKURLSchemeTask { + var request: URLRequest = URLRequest(url: URL(string: "test-scheme://host/resource")!) + + var didReceiveResponseArg: URLResponse? = nil + var didReceiveDataArg: Data? = nil + var didFinishCalled = false + var didFailWithErrorArg: (any Error)? = nil + + func didReceive(_ response: URLResponse) { + didReceiveResponseArg = response + } + + func didReceive(_ data: Data) { + didReceiveDataArg = data + } + + func didFinish() { + didFinishCalled = true + } + + func didFailWithError(_ error: any Error) { + didFailWithErrorArg = error + } +} diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/URLSchemeTaskProxyAPITests.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/URLSchemeTaskProxyAPITests.swift new file mode 100644 index 000000000000..d043157aa89d --- /dev/null +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/URLSchemeTaskProxyAPITests.swift @@ -0,0 +1,99 @@ +// Copyright 2013 The Flutter Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import WebKit +import XCTest + +@testable import webview_flutter_wkwebview + +#if os(iOS) + import Flutter +#elseif os(macOS) + import FlutterMacOS +#endif + +class URLSchemeTaskProxyAPITests: XCTestCase { + func testRequest() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiWKURLSchemeTask(registrar) + + let instance = TestURLSchemeTask() + let value = try? api.pigeonDelegate.request(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value?.value, instance.request) + } + + func testDidReceiveResponse() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiWKURLSchemeTask(registrar) + + let instance = TestURLSchemeTask() + let response = URLResponse( + url: URL(string: "test-scheme://host/resource")!, mimeType: "image/png", + expectedContentLength: 3, textEncodingName: nil) + try? api.pigeonDelegate.didReceiveResponse( + pigeonApi: api, pigeonInstance: instance, response: response) + + XCTAssertEqual(instance.didReceiveResponseArg, response) + } + + func testDidReceiveData() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiWKURLSchemeTask(registrar) + + let instance = TestURLSchemeTask() + let data = Data([1, 2, 3]) + try? api.pigeonDelegate.didReceiveData( + pigeonApi: api, pigeonInstance: instance, data: FlutterStandardTypedData(bytes: data)) + + XCTAssertEqual(instance.didReceiveDataArg, data) + } + + func testDidFinish() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiWKURLSchemeTask(registrar) + + let instance = TestURLSchemeTask() + try? api.pigeonDelegate.didFinish(pigeonApi: api, pigeonInstance: instance) + + XCTAssertTrue(instance.didFinishCalled) + } + + func testDidFailWithError() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiWKURLSchemeTask(registrar) + + let instance = TestURLSchemeTask() + let error = NSError(domain: "domain", code: 42) + try? api.pigeonDelegate.didFailWithError( + pigeonApi: api, pigeonInstance: instance, error: error) + + XCTAssertEqual(instance.didFailWithErrorArg as? NSError, error) + } + + func testCallsAreNoOpsAfterTaskWasStopped() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiWKURLSchemeTask(registrar) + + let instance = TestURLSchemeTask() + URLSchemeTaskState.markStopped(instance) + + let response = URLResponse( + url: URL(string: "test-scheme://host/resource")!, mimeType: nil, + expectedContentLength: 0, textEncodingName: nil) + try? api.pigeonDelegate.didReceiveResponse( + pigeonApi: api, pigeonInstance: instance, response: response) + try? api.pigeonDelegate.didReceiveData( + pigeonApi: api, pigeonInstance: instance, + data: FlutterStandardTypedData(bytes: Data([1]))) + try? api.pigeonDelegate.didFinish(pigeonApi: api, pigeonInstance: instance) + try? api.pigeonDelegate.didFailWithError( + pigeonApi: api, pigeonInstance: instance, error: NSError(domain: "", code: 0)) + + XCTAssertNil(instance.didReceiveResponseArg) + XCTAssertNil(instance.didReceiveDataArg) + XCTAssertFalse(instance.didFinishCalled) + XCTAssertNil(instance.didFailWithErrorArg) + } +} diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/ErrorProxyAPIDelegate.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/ErrorProxyAPIDelegate.swift index 83fa6ab5c880..15fe02e305d5 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/ErrorProxyAPIDelegate.swift +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/ErrorProxyAPIDelegate.swift @@ -9,6 +9,13 @@ import Foundation /// This class may handle instantiating native object instances that are attached to a Dart instance /// or handle method calls on the associated native class or an instance of that class. class ErrorProxyAPIDelegate: PigeonApiDelegateNSError { + func pigeonDefaultConstructor( + pigeonApi: PigeonApiNSError, code: Int64, domain: String, userInfo: [String: Any?] + ) throws -> NSError { + return NSError( + domain: domain, code: Int(code), userInfo: userInfo.compactMapValues { $0 }) + } + func code(pigeonApi: PigeonApiNSError, pigeonInstance: NSError) throws -> Int64 { return Int64(pigeonInstance.code) } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/HTTPURLResponseProxyAPIDelegate.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/HTTPURLResponseProxyAPIDelegate.swift index bf3c01ca1ee0..0ceffd75a5c7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/HTTPURLResponseProxyAPIDelegate.swift +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/HTTPURLResponseProxyAPIDelegate.swift @@ -9,6 +9,29 @@ import Foundation /// This class may handle instantiating native object instances that are attached to a Dart instance /// or handle method calls on the associated native class or an instance of that class. class HTTPURLResponseProxyAPIDelegate: PigeonApiDelegateHTTPURLResponse { + func pigeonDefaultConstructor( + pigeonApi: PigeonApiHTTPURLResponse, statusCode: Int64, url: String, httpVersion: String?, + headerFields: [String: String]? + ) throws -> HTTPURLResponse { + let registrar = pigeonApi.pigeonRegistrar as! ProxyAPIRegistrar + guard let parsedUrl = URL(string: url) else { + throw registrar.createConstructorNullError(type: URL.self, parameters: ["string": url]) + } + guard + let response = HTTPURLResponse( + url: parsedUrl, statusCode: Int(statusCode), httpVersion: httpVersion, + headerFields: headerFields) + else { + throw registrar.createConstructorNullError( + type: HTTPURLResponse.self, + parameters: [ + "url": url, "statusCode": statusCode, "httpVersion": httpVersion, + "headerFields": headerFields, + ]) + } + return response + } + func statusCode(pigeonApi: PigeonApiHTTPURLResponse, pigeonInstance: HTTPURLResponse) throws -> Int64 { diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/ProxyAPIRegistrar.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/ProxyAPIRegistrar.swift index 1d0dc38fac22..0b8fe28d1e82 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/ProxyAPIRegistrar.swift +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/ProxyAPIRegistrar.swift @@ -105,6 +105,27 @@ class ProxyAPIDelegate: WebKitLibraryPigeonProxyApiDelegate { pigeonRegistrar: registrar, delegate: HTTPURLResponseProxyAPIDelegate()) } + func pigeonApiURLResponse(_ registrar: WebKitLibraryPigeonProxyApiRegistrar) + -> PigeonApiURLResponse + { + return PigeonApiURLResponse( + pigeonRegistrar: registrar, delegate: URLResponseProxyAPIDelegate()) + } + + func pigeonApiWKURLSchemeHandler(_ registrar: WebKitLibraryPigeonProxyApiRegistrar) + -> PigeonApiWKURLSchemeHandler + { + return PigeonApiWKURLSchemeHandler( + pigeonRegistrar: registrar, delegate: URLSchemeHandlerProxyAPIDelegate()) + } + + func pigeonApiWKURLSchemeTask(_ registrar: WebKitLibraryPigeonProxyApiRegistrar) + -> PigeonApiWKURLSchemeTask + { + return PigeonApiWKURLSchemeTask( + pigeonRegistrar: registrar, delegate: URLSchemeTaskProxyAPIDelegate()) + } + func pigeonApiWKUserScript(_ registrar: WebKitLibraryPigeonProxyApiRegistrar) -> PigeonApiWKUserScript { diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/URLResponseProxyAPIDelegate.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/URLResponseProxyAPIDelegate.swift new file mode 100644 index 000000000000..855a1587ecd7 --- /dev/null +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/URLResponseProxyAPIDelegate.swift @@ -0,0 +1,24 @@ +// Copyright 2013 The Flutter Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import Foundation + +/// ProxyApi implementation for `URLResponse`. +/// +/// This class may handle instantiating native object instances that are attached to a Dart instance +/// or handle method calls on the associated native class or an instance of that class. +class URLResponseProxyAPIDelegate: PigeonApiDelegateURLResponse { + func pigeonDefaultConstructor( + pigeonApi: PigeonApiURLResponse, url: String, mimeType: String?, expectedContentLength: Int64, + textEncodingName: String? + ) throws -> URLResponse { + guard let parsedUrl = URL(string: url) else { + throw (pigeonApi.pigeonRegistrar as! ProxyAPIRegistrar).createConstructorNullError( + type: URL.self, parameters: ["string": url]) + } + return URLResponse( + url: parsedUrl, mimeType: mimeType, expectedContentLength: Int(expectedContentLength), + textEncodingName: textEncodingName) + } +} diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/URLSchemeHandlerProxyAPIDelegate.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/URLSchemeHandlerProxyAPIDelegate.swift new file mode 100644 index 000000000000..71172f207d94 --- /dev/null +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/URLSchemeHandlerProxyAPIDelegate.swift @@ -0,0 +1,75 @@ +// Copyright 2013 The Flutter Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import WebKit + +/// Tracks whether a `WKURLSchemeTask` has been stopped by the web view. +/// +/// Calling any method of a `WKURLSchemeTask` after the web view has requested +/// the task be stopped raises an `NSException`, so calls coming from Dart must +/// be ignored after `webView(_:stop:)`. The flag is stored as an associated +/// object, so its lifetime is tied to the task instance. All access happens on +/// the main thread (both `WKURLSchemeHandler` callbacks and platform channel +/// messages), so no synchronization is needed. +enum URLSchemeTaskState { + private static var stoppedAssociationKey: UInt8 = 0 + + static func markStopped(_ task: WKURLSchemeTask) { + objc_setAssociatedObject( + task, &stoppedAssociationKey, true, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + + static func isStopped(_ task: WKURLSchemeTask) -> Bool { + return objc_getAssociatedObject(task, &stoppedAssociationKey) as? Bool ?? false + } +} + +/// Implementation of `WKURLSchemeHandler` that calls to Dart in callback methods. +class URLSchemeHandlerImpl: NSObject, WKURLSchemeHandler { + let api: PigeonApiProtocolWKURLSchemeHandler + unowned let registrar: ProxyAPIRegistrar + + init(api: PigeonApiProtocolWKURLSchemeHandler, registrar: ProxyAPIRegistrar) { + self.api = api + self.registrar = registrar + } + + func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) { + registrar.dispatchOnMainThread { onFailure in + self.api.startUrlSchemeTask( + pigeonInstance: self, webView: webView, urlSchemeTask: urlSchemeTask + ) { result in + if case .failure(let error) = result { + onFailure("WKURLSchemeHandler.startUrlSchemeTask", error) + } + } + } + } + + func webView(_ webView: WKWebView, stop urlSchemeTask: WKURLSchemeTask) { + URLSchemeTaskState.markStopped(urlSchemeTask) + registrar.dispatchOnMainThread { onFailure in + self.api.stopUrlSchemeTask( + pigeonInstance: self, webView: webView, urlSchemeTask: urlSchemeTask + ) { result in + if case .failure(let error) = result { + onFailure("WKURLSchemeHandler.stopUrlSchemeTask", error) + } + } + } + } +} + +/// ProxyApi implementation for `WKURLSchemeHandler`. +/// +/// This class may handle instantiating native object instances that are attached to a Dart instance +/// or handle method calls on the associated native class or an instance of that class. +class URLSchemeHandlerProxyAPIDelegate: PigeonApiDelegateWKURLSchemeHandler { + func pigeonDefaultConstructor(pigeonApi: PigeonApiWKURLSchemeHandler) throws + -> WKURLSchemeHandler + { + return URLSchemeHandlerImpl( + api: pigeonApi, registrar: pigeonApi.pigeonRegistrar as! ProxyAPIRegistrar) + } +} diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/URLSchemeTaskProxyAPIDelegate.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/URLSchemeTaskProxyAPIDelegate.swift new file mode 100644 index 000000000000..ffb3548c5db3 --- /dev/null +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/URLSchemeTaskProxyAPIDelegate.swift @@ -0,0 +1,60 @@ +// Copyright 2013 The Flutter Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import WebKit + +#if os(iOS) + import Flutter +#elseif os(macOS) + import FlutterMacOS +#else + #error("Unsupported platform.") +#endif + +/// ProxyApi implementation for `WKURLSchemeTask`. +/// +/// This class may handle instantiating native object instances that are attached to a Dart instance +/// or handle method calls on the associated native class or an instance of that class. +class URLSchemeTaskProxyAPIDelegate: PigeonApiDelegateWKURLSchemeTask { + func request(pigeonApi: PigeonApiWKURLSchemeTask, pigeonInstance: WKURLSchemeTask) throws + -> URLRequestWrapper + { + return URLRequestWrapper(pigeonInstance.request) + } + + func didReceiveResponse( + pigeonApi: PigeonApiWKURLSchemeTask, pigeonInstance: WKURLSchemeTask, response: URLResponse + ) throws { + if URLSchemeTaskState.isStopped(pigeonInstance) { + return + } + pigeonInstance.didReceive(response) + } + + func didReceiveData( + pigeonApi: PigeonApiWKURLSchemeTask, pigeonInstance: WKURLSchemeTask, + data: FlutterStandardTypedData + ) throws { + if URLSchemeTaskState.isStopped(pigeonInstance) { + return + } + pigeonInstance.didReceive(data.data) + } + + func didFinish(pigeonApi: PigeonApiWKURLSchemeTask, pigeonInstance: WKURLSchemeTask) throws { + if URLSchemeTaskState.isStopped(pigeonInstance) { + return + } + pigeonInstance.didFinish() + } + + func didFailWithError( + pigeonApi: PigeonApiWKURLSchemeTask, pigeonInstance: WKURLSchemeTask, error: NSError + ) throws { + if URLSchemeTaskState.isStopped(pigeonInstance) { + return + } + pigeonInstance.didFailWithError(error) + } +} diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/WebKitLibrary.g.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/WebKitLibrary.g.swift index 8848ee4485a5..503c3b76e130 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/WebKitLibrary.g.swift +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/WebKitLibrary.g.swift @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v26.1.5), do not edit directly. +// Autogenerated from Pigeon (v26.3.4), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation @@ -58,7 +58,7 @@ private func wrapError(_ error: Any) -> [Any?] { } return [ "\(error)", - "\(type(of: error))", + "\(Swift.type(of: error))", "Stacktrace: \(Thread.callStackSymbols)", ] } @@ -454,6 +454,14 @@ protocol WebKitLibraryPigeonProxyApiDelegate { /// `WKScriptMessageHandler` to the Dart `InstanceManager` and make calls to Dart. func pigeonApiWKScriptMessageHandler(_ registrar: WebKitLibraryPigeonProxyApiRegistrar) -> PigeonApiWKScriptMessageHandler + /// An implementation of [PigeonApiWKURLSchemeHandler] used to add a new Dart instance of + /// `WKURLSchemeHandler` to the Dart `InstanceManager` and make calls to Dart. + func pigeonApiWKURLSchemeHandler(_ registrar: WebKitLibraryPigeonProxyApiRegistrar) + -> PigeonApiWKURLSchemeHandler + /// An implementation of [PigeonApiWKURLSchemeTask] used to add a new Dart instance of + /// `WKURLSchemeTask` to the Dart `InstanceManager` and make calls to Dart. + func pigeonApiWKURLSchemeTask(_ registrar: WebKitLibraryPigeonProxyApiRegistrar) + -> PigeonApiWKURLSchemeTask /// An implementation of [PigeonApiWKNavigationDelegate] used to add a new Dart instance of /// `WKNavigationDelegate` to the Dart `InstanceManager` and make calls to Dart. func pigeonApiWKNavigationDelegate(_ registrar: WebKitLibraryPigeonProxyApiRegistrar) @@ -520,12 +528,6 @@ protocol WebKitLibraryPigeonProxyApiDelegate { } extension WebKitLibraryPigeonProxyApiDelegate { - func pigeonApiURLResponse(_ registrar: WebKitLibraryPigeonProxyApiRegistrar) - -> PigeonApiURLResponse - { - return PigeonApiURLResponse( - pigeonRegistrar: registrar, delegate: PigeonApiDelegateURLResponse()) - } func pigeonApiWKWebView(_ registrar: WebKitLibraryPigeonProxyApiRegistrar) -> PigeonApiWKWebView { return PigeonApiWKWebView(pigeonRegistrar: registrar, delegate: PigeonApiDelegateWKWebView()) } @@ -573,8 +575,14 @@ open class WebKitLibraryPigeonProxyApiRegistrar { binaryMessenger: binaryMessenger, instanceManager: instanceManager) PigeonApiURLRequest.setUpMessageHandlers( binaryMessenger: binaryMessenger, api: apiDelegate.pigeonApiURLRequest(self)) + PigeonApiHTTPURLResponse.setUpMessageHandlers( + binaryMessenger: binaryMessenger, api: apiDelegate.pigeonApiHTTPURLResponse(self)) + PigeonApiURLResponse.setUpMessageHandlers( + binaryMessenger: binaryMessenger, api: apiDelegate.pigeonApiURLResponse(self)) PigeonApiWKUserScript.setUpMessageHandlers( binaryMessenger: binaryMessenger, api: apiDelegate.pigeonApiWKUserScript(self)) + PigeonApiNSError.setUpMessageHandlers( + binaryMessenger: binaryMessenger, api: apiDelegate.pigeonApiNSError(self)) PigeonApiHTTPCookie.setUpMessageHandlers( binaryMessenger: binaryMessenger, api: apiDelegate.pigeonApiHTTPCookie(self)) PigeonApiAuthenticationChallengeResponse.setUpMessageHandlers( @@ -594,6 +602,10 @@ open class WebKitLibraryPigeonProxyApiRegistrar { binaryMessenger: binaryMessenger, api: apiDelegate.pigeonApiWKPreferences(self)) PigeonApiWKScriptMessageHandler.setUpMessageHandlers( binaryMessenger: binaryMessenger, api: apiDelegate.pigeonApiWKScriptMessageHandler(self)) + PigeonApiWKURLSchemeHandler.setUpMessageHandlers( + binaryMessenger: binaryMessenger, api: apiDelegate.pigeonApiWKURLSchemeHandler(self)) + PigeonApiWKURLSchemeTask.setUpMessageHandlers( + binaryMessenger: binaryMessenger, api: apiDelegate.pigeonApiWKURLSchemeTask(self)) PigeonApiWKNavigationDelegate.setUpMessageHandlers( binaryMessenger: binaryMessenger, api: apiDelegate.pigeonApiWKNavigationDelegate(self)) PigeonApiNSObject.setUpMessageHandlers( @@ -629,7 +641,10 @@ open class WebKitLibraryPigeonProxyApiRegistrar { WebKitLibraryPigeonInstanceManagerApi.setUpMessageHandlers( binaryMessenger: binaryMessenger, instanceManager: nil) PigeonApiURLRequest.setUpMessageHandlers(binaryMessenger: binaryMessenger, api: nil) + PigeonApiHTTPURLResponse.setUpMessageHandlers(binaryMessenger: binaryMessenger, api: nil) + PigeonApiURLResponse.setUpMessageHandlers(binaryMessenger: binaryMessenger, api: nil) PigeonApiWKUserScript.setUpMessageHandlers(binaryMessenger: binaryMessenger, api: nil) + PigeonApiNSError.setUpMessageHandlers(binaryMessenger: binaryMessenger, api: nil) PigeonApiHTTPCookie.setUpMessageHandlers(binaryMessenger: binaryMessenger, api: nil) PigeonApiAuthenticationChallengeResponse.setUpMessageHandlers( binaryMessenger: binaryMessenger, api: nil) @@ -641,6 +656,8 @@ open class WebKitLibraryPigeonProxyApiRegistrar { binaryMessenger: binaryMessenger, api: nil) PigeonApiWKPreferences.setUpMessageHandlers(binaryMessenger: binaryMessenger, api: nil) PigeonApiWKScriptMessageHandler.setUpMessageHandlers(binaryMessenger: binaryMessenger, api: nil) + PigeonApiWKURLSchemeHandler.setUpMessageHandlers(binaryMessenger: binaryMessenger, api: nil) + PigeonApiWKURLSchemeTask.setUpMessageHandlers(binaryMessenger: binaryMessenger, api: nil) PigeonApiWKNavigationDelegate.setUpMessageHandlers(binaryMessenger: binaryMessenger, api: nil) PigeonApiNSObject.setUpMessageHandlers(binaryMessenger: binaryMessenger, api: nil) PigeonApiUIViewWKWebView.setUpMessageHandlers(binaryMessenger: binaryMessenger, api: nil) @@ -914,6 +931,28 @@ private class WebKitLibraryPigeonInternalProxyApiCodecReaderWriter: FlutterStand return } + if let instance = value as? WKURLSchemeHandler { + pigeonRegistrar.apiDelegate.pigeonApiWKURLSchemeHandler(pigeonRegistrar).pigeonNewInstance( + pigeonInstance: instance + ) { _ in } + super.writeByte(128) + super.writeValue( + pigeonRegistrar.instanceManager.identifierWithStrongReference( + forInstance: instance as AnyObject)!) + return + } + + if let instance = value as? WKURLSchemeTask { + pigeonRegistrar.apiDelegate.pigeonApiWKURLSchemeTask(pigeonRegistrar).pigeonNewInstance( + pigeonInstance: instance + ) { _ in } + super.writeByte(128) + super.writeValue( + pigeonRegistrar.instanceManager.identifierWithStrongReference( + forInstance: instance as AnyObject)!) + return + } + if let instance = value as? WKNavigationDelegate { pigeonRegistrar.apiDelegate.pigeonApiWKNavigationDelegate(pigeonRegistrar) .pigeonNewInstance( @@ -1852,6 +1891,11 @@ final class PigeonApiURLRequest: PigeonApiProtocolURLRequest { } } protocol PigeonApiDelegateHTTPURLResponse { + /// Creates an HTTP URL response object with the specified values. + func pigeonDefaultConstructor( + pigeonApi: PigeonApiHTTPURLResponse, statusCode: Int64, url: String, httpVersion: String?, + headerFields: [String: String]? + ) throws -> HTTPURLResponse /// The response’s HTTP status code. func statusCode(pigeonApi: PigeonApiHTTPURLResponse, pigeonInstance: HTTPURLResponse) throws -> Int64 @@ -1875,6 +1919,43 @@ final class PigeonApiHTTPURLResponse: PigeonApiProtocolHTTPURLResponse { self.pigeonRegistrar = pigeonRegistrar self.pigeonDelegate = delegate } + static func setUpMessageHandlers( + binaryMessenger: FlutterBinaryMessenger, api: PigeonApiHTTPURLResponse? + ) { + let codec: FlutterStandardMessageCodec = + api != nil + ? FlutterStandardMessageCodec( + readerWriter: WebKitLibraryPigeonInternalProxyApiCodecReaderWriter( + pigeonRegistrar: api!.pigeonRegistrar)) + : FlutterStandardMessageCodec.sharedInstance() + let pigeonDefaultConstructorChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.webview_flutter_wkwebview.HTTPURLResponse.pigeon_defaultConstructor", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + pigeonDefaultConstructorChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let pigeonIdentifierArg = args[0] as! Int64 + let statusCodeArg = args[1] as! Int64 + let urlArg = args[2] as! String + let httpVersionArg: String? = nilOrValue(args[3]) + let headerFieldsArg: [String: String]? = nilOrValue(args[4]) + do { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + try api.pigeonDelegate.pigeonDefaultConstructor( + pigeonApi: api, statusCode: statusCodeArg, url: urlArg, httpVersion: httpVersionArg, + headerFields: headerFieldsArg), + withIdentifier: pigeonIdentifierArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + pigeonDefaultConstructorChannel.setMessageHandler(nil) + } + } + ///Creates a Dart instance of HTTPURLResponse and attaches it to [pigeonInstance]. func pigeonNewInstance( pigeonInstance: HTTPURLResponse, completion: @escaping (Result) -> Void @@ -1915,7 +1996,12 @@ final class PigeonApiHTTPURLResponse: PigeonApiProtocolHTTPURLResponse { } } } -open class PigeonApiDelegateURLResponse { +protocol PigeonApiDelegateURLResponse { + /// Creates a URL response object with the specified values. + func pigeonDefaultConstructor( + pigeonApi: PigeonApiURLResponse, url: String, mimeType: String?, expectedContentLength: Int64, + textEncodingName: String? + ) throws -> URLResponse } protocol PigeonApiProtocolURLResponse { @@ -1935,6 +2021,43 @@ final class PigeonApiURLResponse: PigeonApiProtocolURLResponse { self.pigeonRegistrar = pigeonRegistrar self.pigeonDelegate = delegate } + static func setUpMessageHandlers( + binaryMessenger: FlutterBinaryMessenger, api: PigeonApiURLResponse? + ) { + let codec: FlutterStandardMessageCodec = + api != nil + ? FlutterStandardMessageCodec( + readerWriter: WebKitLibraryPigeonInternalProxyApiCodecReaderWriter( + pigeonRegistrar: api!.pigeonRegistrar)) + : FlutterStandardMessageCodec.sharedInstance() + let pigeonDefaultConstructorChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.webview_flutter_wkwebview.URLResponse.pigeon_defaultConstructor", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + pigeonDefaultConstructorChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let pigeonIdentifierArg = args[0] as! Int64 + let urlArg = args[1] as! String + let mimeTypeArg: String? = nilOrValue(args[2]) + let expectedContentLengthArg = args[3] as! Int64 + let textEncodingNameArg: String? = nilOrValue(args[4]) + do { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + try api.pigeonDelegate.pigeonDefaultConstructor( + pigeonApi: api, url: urlArg, mimeType: mimeTypeArg, + expectedContentLength: expectedContentLengthArg, textEncodingName: textEncodingNameArg + ), + withIdentifier: pigeonIdentifierArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + pigeonDefaultConstructorChannel.setMessageHandler(nil) + } + } + ///Creates a Dart instance of URLResponse and attaches it to [pigeonInstance]. func pigeonNewInstance( pigeonInstance: URLResponse, completion: @escaping (Result) -> Void @@ -2305,6 +2428,10 @@ final class PigeonApiWKFrameInfo: PigeonApiProtocolWKFrameInfo { } } protocol PigeonApiDelegateNSError { + /// Creates an error object with the specified values. + func pigeonDefaultConstructor( + pigeonApi: PigeonApiNSError, code: Int64, domain: String, userInfo: [String: Any?] + ) throws -> NSError /// The error code. func code(pigeonApi: PigeonApiNSError, pigeonInstance: NSError) throws -> Int64 /// A string containing the error domain. @@ -2328,6 +2455,39 @@ final class PigeonApiNSError: PigeonApiProtocolNSError { self.pigeonRegistrar = pigeonRegistrar self.pigeonDelegate = delegate } + static func setUpMessageHandlers(binaryMessenger: FlutterBinaryMessenger, api: PigeonApiNSError?) + { + let codec: FlutterStandardMessageCodec = + api != nil + ? FlutterStandardMessageCodec( + readerWriter: WebKitLibraryPigeonInternalProxyApiCodecReaderWriter( + pigeonRegistrar: api!.pigeonRegistrar)) + : FlutterStandardMessageCodec.sharedInstance() + let pigeonDefaultConstructorChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.webview_flutter_wkwebview.NSError.pigeon_defaultConstructor", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + pigeonDefaultConstructorChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let pigeonIdentifierArg = args[0] as! Int64 + let codeArg = args[1] as! Int64 + let domainArg = args[2] as! String + let userInfoArg = args[3] as! [String: Any?] + do { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + try api.pigeonDelegate.pigeonDefaultConstructor( + pigeonApi: api, code: codeArg, domain: domainArg, userInfo: userInfoArg), + withIdentifier: pigeonIdentifierArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + pigeonDefaultConstructorChannel.setMessageHandler(nil) + } + } + ///Creates a Dart instance of NSError and attaches it to [pigeonInstance]. func pigeonNewInstance( pigeonInstance: NSError, completion: @escaping (Result) -> Void @@ -3459,6 +3619,16 @@ protocol PigeonApiDelegateWKWebViewConfiguration { func getDefaultWebpagePreferences( pigeonApi: PigeonApiWKWebViewConfiguration, pigeonInstance: WKWebViewConfiguration ) throws -> WKWebpagePreferences + /// Registers an object to load resources associated with the specified URL + /// scheme. + /// + /// This must be called before the web view is created with this + /// configuration. Registering a scheme that WebKit already handles (e.g. + /// `http`, `https`, `file`, `data`, `blob`, or `about`) results in an + /// exception on the native side. + func setURLSchemeHandler( + pigeonApi: PigeonApiWKWebViewConfiguration, pigeonInstance: WKWebViewConfiguration, + handler: WKURLSchemeHandler?, urlScheme: String) throws } protocol PigeonApiProtocolWKWebViewConfiguration { @@ -3702,6 +3872,28 @@ final class PigeonApiWKWebViewConfiguration: PigeonApiProtocolWKWebViewConfigura } else { getDefaultWebpagePreferencesChannel.setMessageHandler(nil) } + let setURLSchemeHandlerChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfiguration.setURLSchemeHandler", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + setURLSchemeHandlerChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let pigeonInstanceArg = args[0] as! WKWebViewConfiguration + let handlerArg: WKURLSchemeHandler? = nilOrValue(args[1]) + let urlSchemeArg = args[2] as! String + do { + try api.pigeonDelegate.setURLSchemeHandler( + pigeonApi: api, pigeonInstance: pigeonInstanceArg, handler: handlerArg, + urlScheme: urlSchemeArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + setURLSchemeHandlerChannel.setMessageHandler(nil) + } } ///Creates a Dart instance of WKWebViewConfiguration and attaches it to [pigeonInstance]. @@ -4177,6 +4369,361 @@ final class PigeonApiWKScriptMessageHandler: PigeonApiProtocolWKScriptMessageHan } } +protocol PigeonApiDelegateWKURLSchemeHandler { + func pigeonDefaultConstructor(pigeonApi: PigeonApiWKURLSchemeHandler) throws -> WKURLSchemeHandler +} + +protocol PigeonApiProtocolWKURLSchemeHandler { + /// Asks the handler to begin loading the data for the specified resource. + func startUrlSchemeTask( + pigeonInstance pigeonInstanceArg: WKURLSchemeHandler, webView webViewArg: WKWebView, + urlSchemeTask urlSchemeTaskArg: WKURLSchemeTask, + completion: @escaping (Result) -> Void) + /// Asks the handler to stop loading the data for the specified resource. + /// + /// After this is called, calling methods on the associated + /// [WKURLSchemeTask] is a no-op. + func stopUrlSchemeTask( + pigeonInstance pigeonInstanceArg: WKURLSchemeHandler, webView webViewArg: WKWebView, + urlSchemeTask urlSchemeTaskArg: WKURLSchemeTask, + completion: @escaping (Result) -> Void) +} + +final class PigeonApiWKURLSchemeHandler: PigeonApiProtocolWKURLSchemeHandler { + unowned let pigeonRegistrar: WebKitLibraryPigeonProxyApiRegistrar + let pigeonDelegate: PigeonApiDelegateWKURLSchemeHandler + ///An implementation of [NSObject] used to access callback methods + var pigeonApiNSObject: PigeonApiNSObject { + return pigeonRegistrar.apiDelegate.pigeonApiNSObject(pigeonRegistrar) + } + + init( + pigeonRegistrar: WebKitLibraryPigeonProxyApiRegistrar, + delegate: PigeonApiDelegateWKURLSchemeHandler + ) { + self.pigeonRegistrar = pigeonRegistrar + self.pigeonDelegate = delegate + } + static func setUpMessageHandlers( + binaryMessenger: FlutterBinaryMessenger, api: PigeonApiWKURLSchemeHandler? + ) { + let codec: FlutterStandardMessageCodec = + api != nil + ? FlutterStandardMessageCodec( + readerWriter: WebKitLibraryPigeonInternalProxyApiCodecReaderWriter( + pigeonRegistrar: api!.pigeonRegistrar)) + : FlutterStandardMessageCodec.sharedInstance() + let pigeonDefaultConstructorChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeHandler.pigeon_defaultConstructor", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + pigeonDefaultConstructorChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let pigeonIdentifierArg = args[0] as! Int64 + do { + api.pigeonRegistrar.instanceManager.addDartCreatedInstance( + try api.pigeonDelegate.pigeonDefaultConstructor(pigeonApi: api), + withIdentifier: pigeonIdentifierArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + pigeonDefaultConstructorChannel.setMessageHandler(nil) + } + } + + ///Creates a Dart instance of WKURLSchemeHandler and attaches it to [pigeonInstance]. + func pigeonNewInstance( + pigeonInstance: WKURLSchemeHandler, completion: @escaping (Result) -> Void + ) { + if pigeonRegistrar.ignoreCallsToDart { + completion( + .failure( + PigeonError( + code: "ignore-calls-error", + message: "Calls to Dart are being ignored.", details: ""))) + } else if pigeonRegistrar.instanceManager.containsInstance(pigeonInstance as AnyObject) { + completion(.success(())) + } else { + completion( + .failure( + PigeonError( + code: "new-instance-error", + message: + "Error: Attempting to create a new Dart instance of WKURLSchemeHandler, but the class has a nonnull callback method.", + details: ""))) + } + } + /// Asks the handler to begin loading the data for the specified resource. + func startUrlSchemeTask( + pigeonInstance pigeonInstanceArg: WKURLSchemeHandler, webView webViewArg: WKWebView, + urlSchemeTask urlSchemeTaskArg: WKURLSchemeTask, + completion: @escaping (Result) -> Void + ) { + if pigeonRegistrar.ignoreCallsToDart { + completion( + .failure( + PigeonError( + code: "ignore-calls-error", + message: "Calls to Dart are being ignored.", details: ""))) + return + } else if !pigeonRegistrar.instanceManager.containsInstance(pigeonInstanceArg as AnyObject) { + completion( + .failure( + PigeonError( + code: "missing-instance-error", + message: + "Callback to `WKURLSchemeHandler.startUrlSchemeTask` failed because native instance was not in the instance manager.", + details: ""))) + return + } + let binaryMessenger = pigeonRegistrar.binaryMessenger + let codec = pigeonRegistrar.codec + let channelName: String = + "dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeHandler.startUrlSchemeTask" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) + channel.sendMessage([pigeonInstanceArg, webViewArg, urlSchemeTaskArg] as [Any?]) { response in + guard let listResponse = response as? [Any?] else { + completion(.failure(createConnectionError(withChannelName: channelName))) + return + } + if listResponse.count > 1 { + let code: String = listResponse[0] as! String + let message: String? = nilOrValue(listResponse[1]) + let details: String? = nilOrValue(listResponse[2]) + completion(.failure(PigeonError(code: code, message: message, details: details))) + } else { + completion(.success(())) + } + } + } + + /// Asks the handler to stop loading the data for the specified resource. + /// + /// After this is called, calling methods on the associated + /// [WKURLSchemeTask] is a no-op. + func stopUrlSchemeTask( + pigeonInstance pigeonInstanceArg: WKURLSchemeHandler, webView webViewArg: WKWebView, + urlSchemeTask urlSchemeTaskArg: WKURLSchemeTask, + completion: @escaping (Result) -> Void + ) { + if pigeonRegistrar.ignoreCallsToDart { + completion( + .failure( + PigeonError( + code: "ignore-calls-error", + message: "Calls to Dart are being ignored.", details: ""))) + return + } else if !pigeonRegistrar.instanceManager.containsInstance(pigeonInstanceArg as AnyObject) { + completion( + .failure( + PigeonError( + code: "missing-instance-error", + message: + "Callback to `WKURLSchemeHandler.stopUrlSchemeTask` failed because native instance was not in the instance manager.", + details: ""))) + return + } + let binaryMessenger = pigeonRegistrar.binaryMessenger + let codec = pigeonRegistrar.codec + let channelName: String = + "dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeHandler.stopUrlSchemeTask" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) + channel.sendMessage([pigeonInstanceArg, webViewArg, urlSchemeTaskArg] as [Any?]) { response in + guard let listResponse = response as? [Any?] else { + completion(.failure(createConnectionError(withChannelName: channelName))) + return + } + if listResponse.count > 1 { + let code: String = listResponse[0] as! String + let message: String? = nilOrValue(listResponse[1]) + let details: String? = nilOrValue(listResponse[2]) + completion(.failure(PigeonError(code: code, message: message, details: details))) + } else { + completion(.success(())) + } + } + } + +} +protocol PigeonApiDelegateWKURLSchemeTask { + /// The request object that describes the resource to load. + func request(pigeonApi: PigeonApiWKURLSchemeTask, pigeonInstance: WKURLSchemeTask) throws + -> URLRequestWrapper + /// Informs WebKit that you created a response object for the request. + /// + /// This is a no-op if the task was already stopped with + /// [WKURLSchemeHandler.stopUrlSchemeTask]. + func didReceiveResponse( + pigeonApi: PigeonApiWKURLSchemeTask, pigeonInstance: WKURLSchemeTask, response: URLResponse) + throws + /// Sends some or all of the resource’s data to WebKit. + /// + /// This is a no-op if the task was already stopped with + /// [WKURLSchemeHandler.stopUrlSchemeTask]. + func didReceiveData( + pigeonApi: PigeonApiWKURLSchemeTask, pigeonInstance: WKURLSchemeTask, + data: FlutterStandardTypedData) throws + /// Informs WebKit that you finished loading the requested data. + /// + /// This is a no-op if the task was already stopped with + /// [WKURLSchemeHandler.stopUrlSchemeTask]. + func didFinish(pigeonApi: PigeonApiWKURLSchemeTask, pigeonInstance: WKURLSchemeTask) throws + /// Sends an error to WebKit indicating that the resource load failed. + /// + /// This is a no-op if the task was already stopped with + /// [WKURLSchemeHandler.stopUrlSchemeTask]. + func didFailWithError( + pigeonApi: PigeonApiWKURLSchemeTask, pigeonInstance: WKURLSchemeTask, error: NSError) throws +} + +protocol PigeonApiProtocolWKURLSchemeTask { +} + +final class PigeonApiWKURLSchemeTask: PigeonApiProtocolWKURLSchemeTask { + unowned let pigeonRegistrar: WebKitLibraryPigeonProxyApiRegistrar + let pigeonDelegate: PigeonApiDelegateWKURLSchemeTask + ///An implementation of [NSObject] used to access callback methods + var pigeonApiNSObject: PigeonApiNSObject { + return pigeonRegistrar.apiDelegate.pigeonApiNSObject(pigeonRegistrar) + } + + init( + pigeonRegistrar: WebKitLibraryPigeonProxyApiRegistrar, + delegate: PigeonApiDelegateWKURLSchemeTask + ) { + self.pigeonRegistrar = pigeonRegistrar + self.pigeonDelegate = delegate + } + static func setUpMessageHandlers( + binaryMessenger: FlutterBinaryMessenger, api: PigeonApiWKURLSchemeTask? + ) { + let codec: FlutterStandardMessageCodec = + api != nil + ? FlutterStandardMessageCodec( + readerWriter: WebKitLibraryPigeonInternalProxyApiCodecReaderWriter( + pigeonRegistrar: api!.pigeonRegistrar)) + : FlutterStandardMessageCodec.sharedInstance() + let didReceiveResponseChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeTask.didReceiveResponse", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + didReceiveResponseChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let pigeonInstanceArg = args[0] as! WKURLSchemeTask + let responseArg = args[1] as! URLResponse + do { + try api.pigeonDelegate.didReceiveResponse( + pigeonApi: api, pigeonInstance: pigeonInstanceArg, response: responseArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + didReceiveResponseChannel.setMessageHandler(nil) + } + let didReceiveDataChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeTask.didReceiveData", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + didReceiveDataChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let pigeonInstanceArg = args[0] as! WKURLSchemeTask + let dataArg = args[1] as! FlutterStandardTypedData + do { + try api.pigeonDelegate.didReceiveData( + pigeonApi: api, pigeonInstance: pigeonInstanceArg, data: dataArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + didReceiveDataChannel.setMessageHandler(nil) + } + let didFinishChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeTask.didFinish", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + didFinishChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let pigeonInstanceArg = args[0] as! WKURLSchemeTask + do { + try api.pigeonDelegate.didFinish(pigeonApi: api, pigeonInstance: pigeonInstanceArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + didFinishChannel.setMessageHandler(nil) + } + let didFailWithErrorChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeTask.didFailWithError", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + didFailWithErrorChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let pigeonInstanceArg = args[0] as! WKURLSchemeTask + let errorArg = args[1] as! NSError + do { + try api.pigeonDelegate.didFailWithError( + pigeonApi: api, pigeonInstance: pigeonInstanceArg, error: errorArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + didFailWithErrorChannel.setMessageHandler(nil) + } + } + + ///Creates a Dart instance of WKURLSchemeTask and attaches it to [pigeonInstance]. + func pigeonNewInstance( + pigeonInstance: WKURLSchemeTask, completion: @escaping (Result) -> Void + ) { + if pigeonRegistrar.ignoreCallsToDart { + completion( + .failure( + PigeonError( + code: "ignore-calls-error", + message: "Calls to Dart are being ignored.", details: ""))) + } else if pigeonRegistrar.instanceManager.containsInstance(pigeonInstance as AnyObject) { + completion(.success(())) + } else { + let pigeonIdentifierArg = pigeonRegistrar.instanceManager.addHostCreatedInstance( + pigeonInstance as AnyObject) + let requestArg = try! pigeonDelegate.request(pigeonApi: self, pigeonInstance: pigeonInstance) + let binaryMessenger = pigeonRegistrar.binaryMessenger + let codec = pigeonRegistrar.codec + let channelName: String = + "dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeTask.pigeon_newInstance" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) + channel.sendMessage([pigeonIdentifierArg, requestArg] as [Any?]) { response in + guard let listResponse = response as? [Any?] else { + completion(.failure(createConnectionError(withChannelName: channelName))) + return + } + if listResponse.count > 1 { + let code: String = listResponse[0] as! String + let message: String? = nilOrValue(listResponse[1]) + let details: String? = nilOrValue(listResponse[2]) + completion(.failure(PigeonError(code: code, message: message, details: details))) + } else { + completion(.success(())) + } + } + } + } +} protocol PigeonApiDelegateWKNavigationDelegate { func pigeonDefaultConstructor(pigeonApi: PigeonApiWKNavigationDelegate) throws -> WKNavigationDelegate diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/WebViewConfigurationProxyAPIDelegate.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/WebViewConfigurationProxyAPIDelegate.swift index 49ddd011b0fd..7c8bd99734a5 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/WebViewConfigurationProxyAPIDelegate.swift +++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/WebViewConfigurationProxyAPIDelegate.swift @@ -98,4 +98,11 @@ class WebViewConfigurationProxyAPIDelegate: PigeonApiDelegateWKWebViewConfigurat ) throws -> WKWebpagePreferences { return pigeonInstance.defaultWebpagePreferences } + + func setURLSchemeHandler( + pigeonApi: PigeonApiWKWebViewConfiguration, pigeonInstance: WKWebViewConfiguration, + handler: WKURLSchemeHandler?, urlScheme: String + ) throws { + pigeonInstance.setURLSchemeHandler(handler, forURLScheme: urlScheme) + } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/integration_test/webview_flutter_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/example/integration_test/webview_flutter_test.dart index 7cdf93cf8ba0..b6436ed9fa48 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/integration_test/webview_flutter_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/integration_test/webview_flutter_test.dart @@ -319,6 +319,254 @@ Future main() async { await expectLater(channelCompleter.future, completion('(null)')); }); + testWidgets('urlSchemeHandlers loads a resource with a custom scheme', ( + WidgetTester tester, + ) async { + final pageFinished = Completer(); + // A 1x1 transparent PNG. + final Uint8List imageBytes = base64Decode( + 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==', + ); + + final requestedUrls = []; + final controller = WebKitWebViewController( + WebKitWebViewControllerCreationParams( + urlSchemeHandlers: { + 'flutter-test': WebKitUrlSchemeHandler( + onStart: (WebKitUrlSchemeTask task) async { + requestedUrls.add(task.url); + await task.didReceiveResponse( + statusCode: 200, + headers: { + 'Content-Type': 'image/png', + 'Content-Length': imageBytes.length.toString(), + }, + ); + await task.didReceiveData(imageBytes); + await task.didFinish(); + }, + ), + }, + ), + ); + unawaited(controller.setJavaScriptMode(JavaScriptMode.unrestricted)); + final delegate = WebKitNavigationDelegate(const WebKitNavigationDelegateCreationParams()); + unawaited(delegate.setOnPageFinished((_) => pageFinished.complete())); + unawaited(controller.setPlatformNavigationDelegate(delegate)); + + final imageLoaded = Completer(); + await controller.addJavaScriptChannel( + JavaScriptChannelParams( + name: 'ImageLoad', + onMessageReceived: (JavaScriptMessage message) { + imageLoaded.complete(message.message); + }, + ), + ); + + await controller.loadHtmlString(''' + + + '''); + + await tester.pumpWidget( + Builder( + builder: (BuildContext context) { + return PlatformWebViewWidget( + PlatformWebViewWidgetCreationParams(controller: controller), + ).build(context); + }, + ), + ); + + await pageFinished.future; + + await expectLater(imageLoaded.future, completion('loaded:1')); + expect(requestedUrls, ['flutter-test://host/image.png']); + }); + + testWidgets('urlSchemeHandlers stops in-flight tasks when the page is replaced', ( + WidgetTester tester, + ) async { + final startedTask = Completer(); + final stoppedTask = Completer(); + final controller = WebKitWebViewController( + WebKitWebViewControllerCreationParams( + urlSchemeHandlers: { + 'flutter-test-stop': WebKitUrlSchemeHandler( + // Deliberately never responds, so the task stays in flight until + // the web view cancels it. + onStart: startedTask.complete, + onStop: stoppedTask.complete, + ), + }, + ), + ); + + await controller.loadHtmlString(''' + + + '''); + + await tester.pumpWidget( + Builder( + builder: (BuildContext context) { + return PlatformWebViewWidget( + PlatformWebViewWidgetCreationParams(controller: controller), + ).build(context); + }, + ), + ); + + final WebKitUrlSchemeTask task = await startedTask.future; + expect(task.isStopped, isFalse); + + // Replacing the page cancels the resource loads of the previous one. + await controller.loadHtmlString('

replaced

'); + + final WebKitUrlSchemeTask stopped = await stoppedTask.future; + expect(stopped, same(task)); + expect(task.isStopped, isTrue); + + // Responding after the task was stopped must be a harmless no-op. + await task.didReceiveResponse(statusCode: 200); + await task.didReceiveData(Uint8List.fromList([1, 2, 3])); + await task.didFinish(); + await task.didFail(); + }); + + testWidgets('urlSchemeHandlers delivers a large response body', (WidgetTester tester) async { + const int bodyLength = 3 * 1024 * 1024; + final controller = WebKitWebViewController( + WebKitWebViewControllerCreationParams( + urlSchemeHandlers: { + 'flutter-test-large': WebKitUrlSchemeHandler( + onStart: (WebKitUrlSchemeTask task) async { + final html = '${'A' * bodyLength}'; + final data = Uint8List.fromList(utf8.encode(html)); + await task.didReceiveResponse( + statusCode: 200, + headers: { + 'Content-Type': 'text/html', + 'Content-Length': data.length.toString(), + }, + ); + await task.didReceiveData(data); + await task.didFinish(); + }, + ), + }, + ), + ); + unawaited(controller.setJavaScriptMode(JavaScriptMode.unrestricted)); + final pageFinished = Completer(); + final delegate = WebKitNavigationDelegate(const WebKitNavigationDelegateCreationParams()); + unawaited(delegate.setOnPageFinished((_) => pageFinished.complete())); + unawaited(controller.setPlatformNavigationDelegate(delegate)); + + // Loads the page itself from the custom scheme, which also covers main + // frame navigation to a custom scheme URL. + await controller.loadRequest( + LoadRequestParams(uri: Uri.parse('flutter-test-large://host/page.html')), + ); + + await tester.pumpWidget( + Builder( + builder: (BuildContext context) { + return PlatformWebViewWidget( + PlatformWebViewWidgetCreationParams(controller: controller), + ).build(context); + }, + ), + ); + + await pageFinished.future; + + final Object result = await controller.runJavaScriptReturningResult( + 'document.body.textContent.length', + ); + expect(result, bodyLength); + }); + + testWidgets('urlSchemeHandlers handles many concurrent requests', (WidgetTester tester) async { + const imageCount = 24; + // A 1x1 transparent PNG. + final Uint8List imageBytes = base64Decode( + 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==', + ); + + final requestedUrls = []; + final controller = WebKitWebViewController( + WebKitWebViewControllerCreationParams( + urlSchemeHandlers: { + 'flutter-test-many': WebKitUrlSchemeHandler( + onStart: (WebKitUrlSchemeTask task) async { + requestedUrls.add(task.url); + await task.didReceiveResponse( + statusCode: 200, + headers: { + 'Content-Type': 'image/png', + 'Content-Length': imageBytes.length.toString(), + }, + ); + await task.didReceiveData(imageBytes); + await task.didFinish(); + }, + ), + }, + ), + ); + unawaited(controller.setJavaScriptMode(JavaScriptMode.unrestricted)); + + final allImagesLoaded = Completer(); + var loadedCount = 0; + await controller.addJavaScriptChannel( + JavaScriptChannelParams( + name: 'ImageCount', + onMessageReceived: (JavaScriptMessage message) { + if (message.message == 'error') { + if (!allImagesLoaded.isCompleted) { + allImagesLoaded.completeError(StateError('An image failed to load.')); + } + return; + } + loadedCount++; + if (loadedCount == imageCount && !allImagesLoaded.isCompleted) { + allImagesLoaded.complete(); + } + }, + ), + ); + + final imgTags = StringBuffer(); + for (var i = 0; i < imageCount; i++) { + imgTags.write( + '", + ); + } + await controller.loadHtmlString('$imgTags'); + + await tester.pumpWidget( + Builder( + builder: (BuildContext context) { + return PlatformWebViewWidget( + PlatformWebViewWidgetCreationParams(controller: controller), + ).build(context); + }, + ), + ); + + await allImagesLoaded.future; + + expect(requestedUrls.toSet(), { + for (var i = 0; i < imageCount; i++) 'flutter-test-many://host/image_$i.png', + }); + }); + testWidgets('resize webview', (WidgetTester tester) async { final buttonTapResizeCompleter = Completer(); final onPageFinished = Completer(); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj index 176440d4d088..76f3bc7c470a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj @@ -24,6 +24,9 @@ 8F1488EB2D2DE27000191744 /* PreferencesProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F1488CF2D2DE27000191744 /* PreferencesProxyAPITests.swift */; }; 8F1488EC2D2DE27000191744 /* FrameInfoProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F1488C62D2DE27000191744 /* FrameInfoProxyAPITests.swift */; }; 8F1488ED2D2DE27000191744 /* ErrorProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F1488C52D2DE27000191744 /* ErrorProxyAPITests.swift */; }; + E6A2538D4B5B4B52B0A3ACC5 /* URLSchemeTaskProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD6D02E9F0C4CADB7FC8619 /* URLSchemeTaskProxyAPITests.swift */; }; + D7C23707126645B685F74BF6 /* URLSchemeHandlerProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EF814FFF37A466282FCD60B /* URLSchemeHandlerProxyAPITests.swift */; }; + 3AEB66D42E6D4A51BBBB8B1B /* URLResponseProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECF7E1D4C86C49E5B696EADF /* URLResponseProxyAPITests.swift */; }; 8F1488EE2D2DE27000191744 /* NSObjectProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F1488CE2D2DE27000191744 /* NSObjectProxyAPITests.swift */; }; 8F1488EF2D2DE27000191744 /* NavigationResponseProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F1488CD2D2DE27000191744 /* NavigationResponseProxyAPITests.swift */; }; 8F1488F02D2DE27000191744 /* UserScriptProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F1488DE2D2DE27000191744 /* UserScriptProxyAPITests.swift */; }; @@ -101,6 +104,9 @@ 8F0E23512EEB5D6B002AB342 /* ColorProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ColorProxyAPITests.swift; path = ../../darwin/Tests/ColorProxyAPITests.swift; sourceTree = SOURCE_ROOT; }; 8F0EDFD22E1F4967001938E6 /* ProxyAPIRegistrarTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ProxyAPIRegistrarTests.swift; path = ../../darwin/Tests/ProxyAPIRegistrarTests.swift; sourceTree = SOURCE_ROOT; }; 8F1488C52D2DE27000191744 /* ErrorProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ErrorProxyAPITests.swift; path = ../../darwin/Tests/ErrorProxyAPITests.swift; sourceTree = SOURCE_ROOT; }; + FFD6D02E9F0C4CADB7FC8619 /* URLSchemeTaskProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = URLSchemeTaskProxyAPITests.swift; path = ../../darwin/Tests/URLSchemeTaskProxyAPITests.swift; sourceTree = SOURCE_ROOT; }; + 9EF814FFF37A466282FCD60B /* URLSchemeHandlerProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = URLSchemeHandlerProxyAPITests.swift; path = ../../darwin/Tests/URLSchemeHandlerProxyAPITests.swift; sourceTree = SOURCE_ROOT; }; + ECF7E1D4C86C49E5B696EADF /* URLResponseProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = URLResponseProxyAPITests.swift; path = ../../darwin/Tests/URLResponseProxyAPITests.swift; sourceTree = SOURCE_ROOT; }; 8F1488C62D2DE27000191744 /* FrameInfoProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FrameInfoProxyAPITests.swift; path = ../../darwin/Tests/FrameInfoProxyAPITests.swift; sourceTree = SOURCE_ROOT; }; 8F1488C72D2DE27000191744 /* FWFWebViewFlutterWKWebViewExternalAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FWFWebViewFlutterWKWebViewExternalAPITests.swift; path = ../../darwin/Tests/FWFWebViewFlutterWKWebViewExternalAPITests.swift; sourceTree = SOURCE_ROOT; }; 8F1488C82D2DE27000191744 /* HTTPCookieProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = HTTPCookieProxyAPITests.swift; path = ../../darwin/Tests/HTTPCookieProxyAPITests.swift; sourceTree = SOURCE_ROOT; }; @@ -188,6 +194,9 @@ 8FEC64842DA2C6DC00C48569 /* WebpagePreferencesProxyAPITests.swift */, 8F1489002D2DE91C00191744 /* AuthenticationChallengeResponseProxyAPITests.swift */, 8F1488C52D2DE27000191744 /* ErrorProxyAPITests.swift */, + FFD6D02E9F0C4CADB7FC8619 /* URLSchemeTaskProxyAPITests.swift */, + 9EF814FFF37A466282FCD60B /* URLSchemeHandlerProxyAPITests.swift */, + ECF7E1D4C86C49E5B696EADF /* URLResponseProxyAPITests.swift */, 8F1488C62D2DE27000191744 /* FrameInfoProxyAPITests.swift */, 8F1488C72D2DE27000191744 /* FWFWebViewFlutterWKWebViewExternalAPITests.swift */, 8F1488C82D2DE27000191744 /* HTTPCookieProxyAPITests.swift */, @@ -491,6 +500,9 @@ 8F1488EB2D2DE27000191744 /* PreferencesProxyAPITests.swift in Sources */, 8F1488EC2D2DE27000191744 /* FrameInfoProxyAPITests.swift in Sources */, 8F1488ED2D2DE27000191744 /* ErrorProxyAPITests.swift in Sources */, + E6A2538D4B5B4B52B0A3ACC5 /* URLSchemeTaskProxyAPITests.swift in Sources */, + D7C23707126645B685F74BF6 /* URLSchemeHandlerProxyAPITests.swift in Sources */, + 3AEB66D42E6D4A51BBBB8B1B /* URLResponseProxyAPITests.swift in Sources */, 8F1488EE2D2DE27000191744 /* NSObjectProxyAPITests.swift in Sources */, 8F1488EF2D2DE27000191744 /* NavigationResponseProxyAPITests.swift in Sources */, 8FEC64852DA2C6DC00C48569 /* GetTrustResultResponseProxyAPITests.swift in Sources */, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/macos/Runner.xcodeproj/project.pbxproj b/packages/webview_flutter/webview_flutter_wkwebview/example/macos/Runner.xcodeproj/project.pbxproj index 115f5c2b3249..429dbe654c7d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/macos/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 60; + objectVersion = 54; objects = { /* Begin PBXAggregateTarget section */ @@ -26,6 +26,7 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; + 60CB95C6378B4789BE3733BE /* URLSchemeTaskProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14FE72D8B6E54C429AF34FAF /* URLSchemeTaskProxyAPITests.swift */; }; 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; 8FEC64952DA303E200C48569 /* SecCertificateProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FEC64922DA303E200C48569 /* SecCertificateProxyAPITests.swift */; }; 8FEC64962DA303E200C48569 /* WebpagePreferencesProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FEC64942DA303E200C48569 /* WebpagePreferencesProxyAPITests.swift */; }; @@ -65,6 +66,10 @@ 8FFBB0692FA1019E00F6659D /* ColorProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FFBB0642FA1019E00F6659D /* ColorProxyAPITests.swift */; }; 8FFBB06A2FA1019E00F6659D /* ProxyAPIRegistrarTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FFBB0662FA1019E00F6659D /* ProxyAPIRegistrarTests.swift */; }; 8FFBB06B2FA1019E00F6659D /* WebViewFlutterPluginTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FFBB0672FA1019E00F6659D /* WebViewFlutterPluginTests.swift */; }; + B2DFEDAB4A014EFA874DE1B2 /* URLResponseProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC74951E00FB4B60A158CE3C /* URLResponseProxyAPITests.swift */; }; + B7B0BBF2C36B4424BEC5E99A /* URLSchemeHandlerProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1E10DE37D75400AB8E92906 /* URLSchemeHandlerProxyAPITests.swift */; }; + D748061DE2C87DBDCC18DF8E /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1045D94ADDB265F1346044B /* Pods_RunnerTests.framework */; }; + E319A455B8F3150896636C79 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D681EEB0BDE272D1CCE6AE72 /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -98,6 +103,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 14FE72D8B6E54C429AF34FAF /* URLSchemeTaskProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = URLSchemeTaskProxyAPITests.swift; path = ../../darwin/Tests/URLSchemeTaskProxyAPITests.swift; sourceTree = SOURCE_ROOT; }; + 2B5361B7CB263BE6D50140A3 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; @@ -113,6 +120,8 @@ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 405D7FA49AA59C1A3AA1EF2A /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; + 6B152D41686CC6F5E48B4729 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 784666492D4C4C64000A1A5F /* FlutterFramework */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterFramework; path = ephemeral/Packages/.packages/FlutterFramework; sourceTree = ""; }; 78DABEA22ED26510000E7860 /* webview_flutter_wkwebview */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = webview_flutter_wkwebview; path = ../../../darwin/webview_flutter_wkwebview; sourceTree = ""; }; 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = ""; }; @@ -157,6 +166,13 @@ 8FFBB0662FA1019E00F6659D /* ProxyAPIRegistrarTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ProxyAPIRegistrarTests.swift; path = ../../darwin/Tests/ProxyAPIRegistrarTests.swift; sourceTree = SOURCE_ROOT; }; 8FFBB0672FA1019E00F6659D /* WebViewFlutterPluginTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = WebViewFlutterPluginTests.swift; path = ../../darwin/Tests/WebViewFlutterPluginTests.swift; sourceTree = SOURCE_ROOT; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; + B1E10DE37D75400AB8E92906 /* URLSchemeHandlerProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = URLSchemeHandlerProxyAPITests.swift; path = ../../darwin/Tests/URLSchemeHandlerProxyAPITests.swift; sourceTree = SOURCE_ROOT; }; + B8008D7ADDBEEA6EBB841E90 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + BF3880335245D63AF1FA4176 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; + CC74951E00FB4B60A158CE3C /* URLResponseProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = URLResponseProxyAPITests.swift; path = ../../darwin/Tests/URLResponseProxyAPITests.swift; sourceTree = SOURCE_ROOT; }; + D681EEB0BDE272D1CCE6AE72 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DF52759E829AF02B7A83312B /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + E1045D94ADDB265F1346044B /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -164,6 +180,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D748061DE2C87DBDCC18DF8E /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -172,6 +189,7 @@ buildActionMask = 2147483647; files = ( 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */, + E319A455B8F3150896636C79 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -191,6 +209,9 @@ 8FEC64942DA303E200C48569 /* WebpagePreferencesProxyAPITests.swift */, 8FF1FE842D37201300A5E400 /* AuthenticationChallengeResponseProxyAPITests.swift */, 8FF1FE852D37201300A5E400 /* ErrorProxyAPITests.swift */, + 14FE72D8B6E54C429AF34FAF /* URLSchemeTaskProxyAPITests.swift */, + B1E10DE37D75400AB8E92906 /* URLSchemeHandlerProxyAPITests.swift */, + CC74951E00FB4B60A158CE3C /* URLResponseProxyAPITests.swift */, 8FF1FE862D37201300A5E400 /* FrameInfoProxyAPITests.swift */, 8FF1FE872D37201300A5E400 /* FWFWebViewFlutterWKWebViewExternalAPITests.swift */, 8FF1FE882D37201300A5E400 /* HTTPCookieProxyAPITests.swift */, @@ -243,6 +264,7 @@ 331C80D6294CF71000263BE5 /* RunnerTests */, 33CC10EE2044A3C60003C045 /* Products */, 57E0600E4AC0FCC05F33A596 /* Pods */, + D9648040379E2A7A756FB7C4 /* Frameworks */, ); sourceTree = ""; }; @@ -296,10 +318,25 @@ 57E0600E4AC0FCC05F33A596 /* Pods */ = { isa = PBXGroup; children = ( + B8008D7ADDBEEA6EBB841E90 /* Pods-Runner.debug.xcconfig */, + DF52759E829AF02B7A83312B /* Pods-Runner.release.xcconfig */, + 6B152D41686CC6F5E48B4729 /* Pods-Runner.profile.xcconfig */, + BF3880335245D63AF1FA4176 /* Pods-RunnerTests.debug.xcconfig */, + 405D7FA49AA59C1A3AA1EF2A /* Pods-RunnerTests.release.xcconfig */, + 2B5361B7CB263BE6D50140A3 /* Pods-RunnerTests.profile.xcconfig */, ); path = Pods; sourceTree = ""; }; + D9648040379E2A7A756FB7C4 /* Frameworks */ = { + isa = PBXGroup; + children = ( + D681EEB0BDE272D1CCE6AE72 /* Pods_Runner.framework */, + E1045D94ADDB265F1346044B /* Pods_RunnerTests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -307,6 +344,7 @@ isa = PBXNativeTarget; buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( + 88797F93407BCBA22BC42D6D /* [CP] Check Pods Manifest.lock */, 331C80D1294CF70F00263BE5 /* Sources */, 331C80D2294CF70F00263BE5 /* Frameworks */, 331C80D3294CF70F00263BE5 /* Resources */, @@ -325,6 +363,7 @@ isa = PBXNativeTarget; buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + CBBBA2AE0975DB4E16BCA197 /* [CP] Check Pods Manifest.lock */, 33CC10E92044A3C60003C045 /* Sources */, 33CC10EA2044A3C60003C045 /* Frameworks */, 33CC10EB2044A3C60003C045 /* Resources */, @@ -385,7 +424,7 @@ ); mainGroup = 33CC10E42044A3C60003C045; packageReferences = ( - 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */, + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */, ); productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; projectDirPath = ""; @@ -456,6 +495,50 @@ shellPath = /bin/sh; shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; }; + 88797F93407BCBA22BC42D6D /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + CBBBA2AE0975DB4E16BCA197 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -482,6 +565,9 @@ 8FF1FEAE2D37201300A5E400 /* NavigationActionProxyAPITests.swift in Sources */, 8FF1FEAF2D37201300A5E400 /* ScrollViewDelegateProxyAPITests.swift in Sources */, 8FF1FEB02D37201300A5E400 /* ErrorProxyAPITests.swift in Sources */, + 60CB95C6378B4789BE3733BE /* URLSchemeTaskProxyAPITests.swift in Sources */, + B7B0BBF2C36B4424BEC5E99A /* URLSchemeHandlerProxyAPITests.swift in Sources */, + B2DFEDAB4A014EFA874DE1B2 /* URLResponseProxyAPITests.swift in Sources */, 8FF1FEB12D37201300A5E400 /* UIDelegateProxyAPITests.swift in Sources */, 8FF1FEB22D37201300A5E400 /* WebViewProxyAPITests.swift in Sources */, 8FF1FEB32D37201300A5E400 /* URLProtectionSpaceProxyAPITests.swift in Sources */, @@ -544,6 +630,7 @@ /* Begin XCBuildConfiguration section */ 331C80DB294CF71000263BE5 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = BF3880335245D63AF1FA4176 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CLANG_ENABLE_MODULES = YES; @@ -561,6 +648,7 @@ }; 331C80DC294CF71000263BE5 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 405D7FA49AA59C1A3AA1EF2A /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CLANG_ENABLE_MODULES = YES; @@ -577,6 +665,7 @@ }; 331C80DD294CF71000263BE5 /* Profile */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 2B5361B7CB263BE6D50140A3 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CLANG_ENABLE_MODULES = YES; @@ -864,7 +953,7 @@ /* End XCConfigurationList section */ /* Begin XCLocalSwiftPackageReference section */ - 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */ = { + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = { isa = XCLocalSwiftPackageReference; relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; }; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.g.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.g.dart index 423e4b1154c9..4d17d34f8fc7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.g.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.g.dart @@ -1,24 +1,42 @@ // Copyright 2013 The Flutter Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v26.1.5), do not edit directly. +// Autogenerated from Pigeon (v26.3.4), do not edit directly. // See also: https://pub.dev/packages/pigeon -// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers +// ignore_for_file: unused_import, unused_shown_name +// ignore_for_file: type=lint import 'dart:async'; import 'dart:io' show Platform; -import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; +import 'dart:typed_data' show Float64List, Int32List, Int64List; -import 'package:flutter/foundation.dart' - show ReadBuffer, WriteBuffer, immutable, protected, visibleForTesting; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart' show WidgetsFlutterBinding; - -PlatformException _createConnectionError(String channelName) { - return PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel: "$channelName".', - ); +import 'package:meta/meta.dart' show immutable, protected, visibleForTesting; + +Object? _extractReplyValueOrThrow( + List? replyList, + String channelName, { + required bool isNullValid, +}) { + if (replyList == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel: "$channelName".', + ); + } else if (replyList.length > 1) { + throw PlatformException( + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], + ); + } else if (!isNullValid && (replyList.isNotEmpty && replyList[0] == null)) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } + return replyList.firstOrNull; } List wrapResponse({Object? result, PlatformException? error, bool empty = false}) { @@ -53,6 +71,38 @@ class PigeonOverrides { })? uRLRequest_new; + /// Overrides [HTTPURLResponse.new]. + static HTTPURLResponse Function({ + required int statusCode, + required String url, + void Function( + NSObject pigeon_instance, + String? keyPath, + NSObject? object, + Map? change, + )? + observeValue, + String? httpVersion, + Map? headerFields, + })? + hTTPURLResponse_new; + + /// Overrides [URLResponse.new]. + static URLResponse Function({ + required String url, + required int expectedContentLength, + void Function( + NSObject pigeon_instance, + String? keyPath, + NSObject? object, + Map? change, + )? + observeValue, + String? mimeType, + String? textEncodingName, + })? + uRLResponse_new; + /// Overrides [WKUserScript.new]. static WKUserScript Function({ required String source, @@ -68,6 +118,21 @@ class PigeonOverrides { })? wKUserScript_new; + /// Overrides [NSError.new]. + static NSError Function({ + required int code, + required String domain, + required Map userInfo, + void Function( + NSObject pigeon_instance, + String? keyPath, + NSObject? object, + Map? change, + )? + observeValue, + })? + nSError_new; + /// Overrides [HTTPCookie.new]. static HTTPCookie Function({ required Map properties, @@ -118,6 +183,30 @@ class PigeonOverrides { })? wKScriptMessageHandler_new; + /// Overrides [WKURLSchemeHandler.new]. + static WKURLSchemeHandler Function({ + required void Function( + WKURLSchemeHandler pigeon_instance, + WKWebView webView, + WKURLSchemeTask urlSchemeTask, + ) + startUrlSchemeTask, + required void Function( + WKURLSchemeHandler pigeon_instance, + WKWebView webView, + WKURLSchemeTask urlSchemeTask, + ) + stopUrlSchemeTask, + void Function( + NSObject pigeon_instance, + String? keyPath, + NSObject? object, + Map? change, + )? + observeValue, + })? + wKURLSchemeHandler_new; + /// Overrides [WKNavigationDelegate.new]. static WKNavigationDelegate Function({ required Future Function( @@ -333,13 +422,17 @@ class PigeonOverrides { /// Sets all overridden ProxyApi class members to null. static void pigeon_reset() { uRLRequest_new = null; + hTTPURLResponse_new = null; + uRLResponse_new = null; wKUserScript_new = null; + nSError_new = null; hTTPCookie_new = null; authenticationChallengeResponse_new = null; authenticationChallengeResponse_createAsync = null; wKWebsiteDataStore_defaultDataStore = null; wKWebViewConfiguration_new = null; wKScriptMessageHandler_new = null; + wKURLSchemeHandler_new = null; wKNavigationDelegate_new = null; nSObject_new = null; uIViewWKWebView_new = null; @@ -486,6 +579,8 @@ class PigeonInstanceManager { WKUserContentController.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager); WKPreferences.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager); WKScriptMessageHandler.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager); + WKURLSchemeHandler.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager); + WKURLSchemeTask.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager); WKNavigationDelegate.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager); NSObject.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager); UIViewWKWebView.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager); @@ -659,18 +754,10 @@ class _PigeonInternalInstanceManagerApi { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.PigeonInternalInstanceManager.removeStrongReference was null.', - ); - final List args = (message as List?)!; - final int? arg_identifier = (args[0] as int?); - assert( - arg_identifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.PigeonInternalInstanceManager.removeStrongReference was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_identifier = args[0]! as int; try { - (instanceManager ?? PigeonInstanceManager.instance).remove(arg_identifier!); + (instanceManager ?? PigeonInstanceManager.instance).remove(arg_identifier); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); @@ -694,17 +781,8 @@ class _PigeonInternalInstanceManagerApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([identifier]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Clear the native `PigeonInstanceManager`. @@ -720,17 +798,8 @@ class _PigeonInternalInstanceManagerApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } } @@ -1277,17 +1346,8 @@ class URLRequest extends NSObject { ]); () async { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); } @@ -1325,16 +1385,8 @@ class URLRequest extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.URLRequest.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.URLRequest.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -1342,7 +1394,7 @@ class URLRequest extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -1369,17 +1421,13 @@ class URLRequest extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return (pigeonVar_replyList[0] as String?); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return pigeonVar_replyValue as String?; } /// The HTTP request method. @@ -1395,17 +1443,8 @@ class URLRequest extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, method]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The HTTP request method. @@ -1421,17 +1460,13 @@ class URLRequest extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return (pigeonVar_replyList[0] as String?); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return pigeonVar_replyValue as String?; } /// The request body. @@ -1447,17 +1482,8 @@ class URLRequest extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, body]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The request body. @@ -1473,17 +1499,13 @@ class URLRequest extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return (pigeonVar_replyList[0] as Uint8List?); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return pigeonVar_replyValue as Uint8List?; } /// A dictionary containing all of the HTTP header fields for a request. @@ -1499,17 +1521,8 @@ class URLRequest extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, fields]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// A dictionary containing all of the HTTP header fields for a request. @@ -1525,17 +1538,13 @@ class URLRequest extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return (pigeonVar_replyList[0] as Map?)?.cast(); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return (pigeonVar_replyValue as Map?)?.cast(); } @override @@ -1553,6 +1562,77 @@ class URLRequest extends NSObject { /// /// See https://developer.apple.com/documentation/foundation/httpurlresponse. class HTTPURLResponse extends URLResponse { + /// Creates an HTTP URL response object with the specified values. + factory HTTPURLResponse({ + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + required int statusCode, + void Function( + NSObject pigeon_instance, + String? keyPath, + NSObject? object, + Map? change, + )? + observeValue, + required String url, + String? httpVersion, + Map? headerFields, + }) { + if (PigeonOverrides.hTTPURLResponse_new != null) { + return PigeonOverrides.hTTPURLResponse_new!( + statusCode: statusCode, + observeValue: observeValue, + url: url, + httpVersion: httpVersion, + headerFields: headerFields, + ); + } + return HTTPURLResponse.pigeon_new( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + statusCode: statusCode, + observeValue: observeValue, + url: url, + httpVersion: httpVersion, + headerFields: headerFields, + ); + } + + /// Creates an HTTP URL response object with the specified values. + @protected + HTTPURLResponse.pigeon_new({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.statusCode, + super.observeValue, + required String url, + String? httpVersion, + Map? headerFields, + }) : super.pigeon_detached() { + final int pigeonVar_instanceIdentifier = pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = _pigeonVar_codecHTTPURLResponse; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const pigeonVar_channelName = + 'dev.flutter.pigeon.webview_flutter_wkwebview.HTTPURLResponse.pigeon_defaultConstructor'; + final pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([ + pigeonVar_instanceIdentifier, + statusCode, + url, + httpVersion, + headerFields, + ]); + () async { + final pigeonVar_replyList = await pigeonVar_sendFuture as List?; + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); + }(); + } + /// Constructs [HTTPURLResponse] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -1565,6 +1645,9 @@ class HTTPURLResponse extends URLResponse { super.observeValue, }) : super.pigeon_detached(); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecHTTPURLResponse = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); + /// The response’s HTTP status code. final int statusCode; @@ -1588,30 +1671,18 @@ class HTTPURLResponse extends URLResponse { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.HTTPURLResponse.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.HTTPURLResponse.pigeon_newInstance was null, expected non-null int.', - ); - final int? arg_statusCode = (args[1] as int?); - assert( - arg_statusCode != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.HTTPURLResponse.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; + final int arg_statusCode = args[1]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( - pigeon_newInstance?.call(arg_statusCode!) ?? + pigeon_newInstance?.call(arg_statusCode) ?? HTTPURLResponse.pigeon_detached( pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, - statusCode: arg_statusCode!, + statusCode: arg_statusCode, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -1642,6 +1713,77 @@ class HTTPURLResponse extends URLResponse { /// /// See https://developer.apple.com/documentation/foundation/urlresponse. class URLResponse extends NSObject { + /// Creates a URL response object with the specified values. + factory URLResponse({ + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + void Function( + NSObject pigeon_instance, + String? keyPath, + NSObject? object, + Map? change, + )? + observeValue, + required String url, + String? mimeType, + required int expectedContentLength, + String? textEncodingName, + }) { + if (PigeonOverrides.uRLResponse_new != null) { + return PigeonOverrides.uRLResponse_new!( + observeValue: observeValue, + url: url, + mimeType: mimeType, + expectedContentLength: expectedContentLength, + textEncodingName: textEncodingName, + ); + } + return URLResponse.pigeon_new( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + observeValue: observeValue, + url: url, + mimeType: mimeType, + expectedContentLength: expectedContentLength, + textEncodingName: textEncodingName, + ); + } + + /// Creates a URL response object with the specified values. + @protected + URLResponse.pigeon_new({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + super.observeValue, + required String url, + String? mimeType, + required int expectedContentLength, + String? textEncodingName, + }) : super.pigeon_detached() { + final int pigeonVar_instanceIdentifier = pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = _pigeonVar_codecURLResponse; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const pigeonVar_channelName = + 'dev.flutter.pigeon.webview_flutter_wkwebview.URLResponse.pigeon_defaultConstructor'; + final pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([ + pigeonVar_instanceIdentifier, + url, + mimeType, + expectedContentLength, + textEncodingName, + ]); + () async { + final pigeonVar_replyList = await pigeonVar_sendFuture as List?; + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); + }(); + } + /// Constructs [URLResponse] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -1653,6 +1795,9 @@ class URLResponse extends NSObject { super.observeValue, }) : super.pigeon_detached(); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecURLResponse = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); + static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, BinaryMessenger? pigeon_binaryMessenger, @@ -1673,16 +1818,8 @@ class URLResponse extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.URLResponse.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.URLResponse.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -1690,7 +1827,7 @@ class URLResponse extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -1782,17 +1919,8 @@ class WKUserScript extends NSObject { ]); () async { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); } @@ -1848,42 +1976,22 @@ class WKUserScript extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUserScript.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUserScript.pigeon_newInstance was null, expected non-null int.', - ); - final String? arg_source = (args[1] as String?); - assert( - arg_source != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUserScript.pigeon_newInstance was null, expected non-null String.', - ); - final UserScriptInjectionTime? arg_injectionTime = (args[2] as UserScriptInjectionTime?); - assert( - arg_injectionTime != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUserScript.pigeon_newInstance was null, expected non-null UserScriptInjectionTime.', - ); - final bool? arg_isForMainFrameOnly = (args[3] as bool?); - assert( - arg_isForMainFrameOnly != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUserScript.pigeon_newInstance was null, expected non-null bool.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; + final String arg_source = args[1]! as String; + final UserScriptInjectionTime arg_injectionTime = args[2]! as UserScriptInjectionTime; + final bool arg_isForMainFrameOnly = args[3]! as bool; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( - pigeon_newInstance?.call(arg_source!, arg_injectionTime!, arg_isForMainFrameOnly!) ?? + pigeon_newInstance?.call(arg_source, arg_injectionTime, arg_isForMainFrameOnly) ?? WKUserScript.pigeon_detached( pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, - source: arg_source!, - injectionTime: arg_injectionTime!, - isForMainFrameOnly: arg_isForMainFrameOnly!, + source: arg_source, + injectionTime: arg_injectionTime, + isForMainFrameOnly: arg_isForMainFrameOnly, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -1966,38 +2074,22 @@ class WKNavigationAction extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationAction.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationAction.pigeon_newInstance was null, expected non-null int.', - ); - final URLRequest? arg_request = (args[1] as URLRequest?); - assert( - arg_request != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationAction.pigeon_newInstance was null, expected non-null URLRequest.', - ); - final WKFrameInfo? arg_targetFrame = (args[2] as WKFrameInfo?); - final NavigationType? arg_navigationType = (args[3] as NavigationType?); - assert( - arg_navigationType != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationAction.pigeon_newInstance was null, expected non-null NavigationType.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; + final URLRequest arg_request = args[1]! as URLRequest; + final WKFrameInfo? arg_targetFrame = args[2] as WKFrameInfo?; + final NavigationType arg_navigationType = args[3]! as NavigationType; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( - pigeon_newInstance?.call(arg_request!, arg_targetFrame, arg_navigationType!) ?? + pigeon_newInstance?.call(arg_request, arg_targetFrame, arg_navigationType) ?? WKNavigationAction.pigeon_detached( pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, - request: arg_request!, + request: arg_request, targetFrame: arg_targetFrame, - navigationType: arg_navigationType!, + navigationType: arg_navigationType, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -2070,36 +2162,20 @@ class WKNavigationResponse extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationResponse.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationResponse.pigeon_newInstance was null, expected non-null int.', - ); - final URLResponse? arg_response = (args[1] as URLResponse?); - assert( - arg_response != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationResponse.pigeon_newInstance was null, expected non-null URLResponse.', - ); - final bool? arg_isForMainFrame = (args[2] as bool?); - assert( - arg_isForMainFrame != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationResponse.pigeon_newInstance was null, expected non-null bool.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; + final URLResponse arg_response = args[1]! as URLResponse; + final bool arg_isForMainFrame = args[2]! as bool; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( - pigeon_newInstance?.call(arg_response!, arg_isForMainFrame!) ?? + pigeon_newInstance?.call(arg_response, arg_isForMainFrame) ?? WKNavigationResponse.pigeon_detached( pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, - response: arg_response!, - isForMainFrame: arg_isForMainFrame!, + response: arg_response, + isForMainFrame: arg_isForMainFrame, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -2170,32 +2246,20 @@ class WKFrameInfo extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKFrameInfo.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKFrameInfo.pigeon_newInstance was null, expected non-null int.', - ); - final bool? arg_isMainFrame = (args[1] as bool?); - assert( - arg_isMainFrame != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKFrameInfo.pigeon_newInstance was null, expected non-null bool.', - ); - final URLRequest? arg_request = (args[2] as URLRequest?); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; + final bool arg_isMainFrame = args[1]! as bool; + final URLRequest? arg_request = args[2] as URLRequest?; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( - pigeon_newInstance?.call(arg_isMainFrame!, arg_request) ?? + pigeon_newInstance?.call(arg_isMainFrame, arg_request) ?? WKFrameInfo.pigeon_detached( pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, - isMainFrame: arg_isMainFrame!, + isMainFrame: arg_isMainFrame, request: arg_request, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -2227,6 +2291,72 @@ class WKFrameInfo extends NSObject { /// /// See https://developer.apple.com/documentation/foundation/nserror. class NSError extends NSObject { + /// Creates an error object with the specified values. + factory NSError({ + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + required int code, + required String domain, + required Map userInfo, + void Function( + NSObject pigeon_instance, + String? keyPath, + NSObject? object, + Map? change, + )? + observeValue, + }) { + if (PigeonOverrides.nSError_new != null) { + return PigeonOverrides.nSError_new!( + code: code, + domain: domain, + userInfo: userInfo, + observeValue: observeValue, + ); + } + return NSError.pigeon_new( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + code: code, + domain: domain, + userInfo: userInfo, + observeValue: observeValue, + ); + } + + /// Creates an error object with the specified values. + @protected + NSError.pigeon_new({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.code, + required this.domain, + required this.userInfo, + super.observeValue, + }) : super.pigeon_detached() { + final int pigeonVar_instanceIdentifier = pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = _pigeonVar_codecNSError; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const pigeonVar_channelName = + 'dev.flutter.pigeon.webview_flutter_wkwebview.NSError.pigeon_defaultConstructor'; + final pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([ + pigeonVar_instanceIdentifier, + code, + domain, + userInfo, + ]); + () async { + final pigeonVar_replyList = await pigeonVar_sendFuture as List?; + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); + }(); + } + /// Constructs [NSError] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -2241,6 +2371,9 @@ class NSError extends NSObject { super.observeValue, }) : super.pigeon_detached(); + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecNSError = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); + /// The error code. final int code; @@ -2270,43 +2403,23 @@ class NSError extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.NSError.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.NSError.pigeon_newInstance was null, expected non-null int.', - ); - final int? arg_code = (args[1] as int?); - assert( - arg_code != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.NSError.pigeon_newInstance was null, expected non-null int.', - ); - final String? arg_domain = (args[2] as String?); - assert( - arg_domain != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.NSError.pigeon_newInstance was null, expected non-null String.', - ); - final Map? arg_userInfo = (args[3] as Map?) - ?.cast(); - assert( - arg_userInfo != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.NSError.pigeon_newInstance was null, expected non-null Map.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; + final int arg_code = args[1]! as int; + final String arg_domain = args[2]! as String; + final Map arg_userInfo = (args[3]! as Map) + .cast(); try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( - pigeon_newInstance?.call(arg_code!, arg_domain!, arg_userInfo!) ?? + pigeon_newInstance?.call(arg_code, arg_domain, arg_userInfo) ?? NSError.pigeon_detached( pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, - code: arg_code!, - domain: arg_domain!, - userInfo: arg_userInfo!, + code: arg_code, + domain: arg_domain, + userInfo: arg_userInfo, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -2378,32 +2491,20 @@ class WKScriptMessage extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKScriptMessage.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKScriptMessage.pigeon_newInstance was null, expected non-null int.', - ); - final String? arg_name = (args[1] as String?); - assert( - arg_name != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKScriptMessage.pigeon_newInstance was null, expected non-null String.', - ); - final Object? arg_body = (args[2] as Object?); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; + final String arg_name = args[1]! as String; + final Object? arg_body = args[2]; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( - pigeon_newInstance?.call(arg_name!, arg_body) ?? + pigeon_newInstance?.call(arg_name, arg_body) ?? WKScriptMessage.pigeon_detached( pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, - name: arg_name!, + name: arg_name, body: arg_body, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -2477,42 +2578,22 @@ class WKSecurityOrigin extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKSecurityOrigin.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKSecurityOrigin.pigeon_newInstance was null, expected non-null int.', - ); - final String? arg_host = (args[1] as String?); - assert( - arg_host != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKSecurityOrigin.pigeon_newInstance was null, expected non-null String.', - ); - final int? arg_port = (args[2] as int?); - assert( - arg_port != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKSecurityOrigin.pigeon_newInstance was null, expected non-null int.', - ); - final String? arg_securityProtocol = (args[3] as String?); - assert( - arg_securityProtocol != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKSecurityOrigin.pigeon_newInstance was null, expected non-null String.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; + final String arg_host = args[1]! as String; + final int arg_port = args[2]! as int; + final String arg_securityProtocol = args[3]! as String; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( - pigeon_newInstance?.call(arg_host!, arg_port!, arg_securityProtocol!) ?? + pigeon_newInstance?.call(arg_host, arg_port, arg_securityProtocol) ?? WKSecurityOrigin.pigeon_detached( pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, - host: arg_host!, - port: arg_port!, - securityProtocol: arg_securityProtocol!, + host: arg_host, + port: arg_port, + securityProtocol: arg_securityProtocol, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -2590,17 +2671,8 @@ class HTTPCookie extends NSObject { ]); () async { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); } @@ -2638,16 +2710,8 @@ class HTTPCookie extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.HTTPCookie.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.HTTPCookie.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -2655,7 +2719,7 @@ class HTTPCookie extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -2683,18 +2747,13 @@ class HTTPCookie extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return (pigeonVar_replyList[0] as Map?) - ?.cast(); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return (pigeonVar_replyValue as Map?)?.cast(); } @override @@ -2767,17 +2826,8 @@ class AuthenticationChallengeResponse extends PigeonInternalProxyApiBaseClass { ]); () async { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); } @@ -2827,33 +2877,21 @@ class AuthenticationChallengeResponse extends PigeonInternalProxyApiBaseClass { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.AuthenticationChallengeResponse.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.AuthenticationChallengeResponse.pigeon_newInstance was null, expected non-null int.', - ); - final UrlSessionAuthChallengeDisposition? arg_disposition = - (args[1] as UrlSessionAuthChallengeDisposition?); - assert( - arg_disposition != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.AuthenticationChallengeResponse.pigeon_newInstance was null, expected non-null UrlSessionAuthChallengeDisposition.', - ); - final URLCredential? arg_credential = (args[2] as URLCredential?); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; + final UrlSessionAuthChallengeDisposition arg_disposition = + args[1]! as UrlSessionAuthChallengeDisposition; + final URLCredential? arg_credential = args[2] as URLCredential?; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( - pigeon_newInstance?.call(arg_disposition!, arg_credential) ?? + pigeon_newInstance?.call(arg_disposition, arg_credential) ?? AuthenticationChallengeResponse.pigeon_detached( pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, - disposition: arg_disposition!, + disposition: arg_disposition, credential: arg_credential, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -2898,22 +2936,13 @@ class AuthenticationChallengeResponse extends PigeonInternalProxyApiBaseClass { credential, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as AuthenticationChallengeResponse?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as AuthenticationChallengeResponse; } @override @@ -2976,16 +3005,8 @@ class WKWebsiteDataStore extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKWebsiteDataStore.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKWebsiteDataStore.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -2993,7 +3014,7 @@ class WKWebsiteDataStore extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -3030,17 +3051,8 @@ class WKWebsiteDataStore extends NSObject { pigeonVar_instanceIdentifier, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); return pigeonVar_instance; } @@ -3068,17 +3080,8 @@ class WKWebsiteDataStore extends NSObject { pigeonVar_instanceIdentifier, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); return pigeonVar_instance; } @@ -3103,22 +3106,13 @@ class WKWebsiteDataStore extends NSObject { modificationTimeInSecondsSinceEpoch, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as bool?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as bool; } @override @@ -3169,16 +3163,8 @@ class UIView extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIView.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIView.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -3186,7 +3172,7 @@ class UIView extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -3214,17 +3200,8 @@ class UIView extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, value]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// A Boolean value that determines whether the view is opaque. @@ -3239,17 +3216,8 @@ class UIView extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, opaque]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } @override @@ -3300,16 +3268,8 @@ class UIScrollView extends UIView { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollView.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollView.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -3317,7 +3277,7 @@ class UIScrollView extends UIView { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -3346,22 +3306,13 @@ class UIScrollView extends UIView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as List?)!.cast(); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return (pigeonVar_replyValue! as List).cast(); } /// Move the scrolled position of your view. @@ -3379,17 +3330,8 @@ class UIScrollView extends UIView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, x, y]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The point at which the origin of the content view is offset from the @@ -3406,17 +3348,8 @@ class UIScrollView extends UIView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, x, y]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The delegate of the scroll view. @@ -3432,17 +3365,8 @@ class UIScrollView extends UIView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, delegate]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Whether the scroll view bounces past the edge of content and back again. @@ -3458,17 +3382,8 @@ class UIScrollView extends UIView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, value]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Whether the scroll view bounces when it reaches the ends of its horizontal @@ -3485,17 +3400,8 @@ class UIScrollView extends UIView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, value]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Whether the scroll view bounces when it reaches the ends of its vertical @@ -3512,17 +3418,8 @@ class UIScrollView extends UIView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, value]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Whether bouncing always occurs when vertical scrolling reaches the end of @@ -3543,17 +3440,8 @@ class UIScrollView extends UIView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, value]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Whether bouncing always occurs when horizontal scrolling reaches the end @@ -3574,17 +3462,8 @@ class UIScrollView extends UIView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, value]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Whether the vertical scroll indicator is visible. @@ -3602,17 +3481,8 @@ class UIScrollView extends UIView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, value]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Whether the horizontal scroll indicator is visible. @@ -3630,17 +3500,8 @@ class UIScrollView extends UIView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, value]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } @override @@ -3700,17 +3561,8 @@ class WKWebViewConfiguration extends NSObject { ]); () async { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); } @@ -3748,16 +3600,8 @@ class WKWebViewConfiguration extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfiguration.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfiguration.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -3765,7 +3609,7 @@ class WKWebViewConfiguration extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -3798,17 +3642,8 @@ class WKWebViewConfiguration extends NSObject { controller, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The object that coordinates interactions between your app’s native code @@ -3826,22 +3661,13 @@ class WKWebViewConfiguration extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as WKUserContentController?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as WKUserContentController; } /// The object you use to get and set the site’s cookies and to track the @@ -3859,17 +3685,8 @@ class WKWebViewConfiguration extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, dataStore]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The object you use to get and set the site’s cookies and to track the @@ -3887,22 +3704,13 @@ class WKWebViewConfiguration extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as WKWebsiteDataStore?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as WKWebsiteDataStore; } /// The object that manages the preference-related settings for the web view. @@ -3922,17 +3730,8 @@ class WKWebViewConfiguration extends NSObject { preferences, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The object that manages the preference-related settings for the web view. @@ -3949,22 +3748,13 @@ class WKWebViewConfiguration extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as WKPreferences?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as WKPreferences; } /// A Boolean value that indicates whether HTML5 videos play inline or use the @@ -3982,17 +3772,8 @@ class WKWebViewConfiguration extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, allow]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// A Boolean value that indicates whether the web view limits navigation to @@ -4010,17 +3791,8 @@ class WKWebViewConfiguration extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, limit]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The media types that require a user gesture to begin playing. @@ -4037,17 +3809,8 @@ class WKWebViewConfiguration extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, type]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The default preferences to use when loading and rendering content. @@ -4064,22 +3827,41 @@ class WKWebViewConfiguration extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as WKWebpagePreferences?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as WKWebpagePreferences; + } + + /// Registers an object to load resources associated with the specified URL + /// scheme. + /// + /// This must be called before the web view is created with this + /// configuration. Registering a scheme that WebKit already handles (e.g. + /// `http`, `https`, `file`, `data`, `blob`, or `about`) results in an + /// exception on the native side. + Future setURLSchemeHandler(WKURLSchemeHandler? handler, String urlScheme) async { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecWKWebViewConfiguration; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const pigeonVar_channelName = + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfiguration.setURLSchemeHandler'; + final pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([ + this, + handler, + urlScheme, + ]); + final pigeonVar_replyList = await pigeonVar_sendFuture as List?; + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } @override @@ -4131,16 +3913,8 @@ class WKUserContentController extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUserContentController.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUserContentController.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -4148,7 +3922,7 @@ class WKUserContentController extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -4181,17 +3955,8 @@ class WKUserContentController extends NSObject { name, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Uninstalls the custom message handler with the specified name from your @@ -4209,17 +3974,8 @@ class WKUserContentController extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, name]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Uninstalls all custom message handlers associated with the user content @@ -4237,17 +3993,8 @@ class WKUserContentController extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Injects the specified script into the webpage’s content. @@ -4267,17 +4014,8 @@ class WKUserContentController extends NSObject { userScript, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Removes all user scripts from the web view. @@ -4294,17 +4032,8 @@ class WKUserContentController extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } @override @@ -4355,16 +4084,8 @@ class WKPreferences extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKPreferences.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKPreferences.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -4372,7 +4093,7 @@ class WKPreferences extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -4400,17 +4121,8 @@ class WKPreferences extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, enabled]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Set a Boolean value that indicates whether JavaScript can open windows @@ -4429,17 +4141,8 @@ class WKPreferences extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, enabled]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } @override @@ -4510,17 +4213,8 @@ class WKScriptMessageHandler extends NSObject { ]); () async { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); } @@ -4590,31 +4284,15 @@ class WKScriptMessageHandler extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKScriptMessageHandler.didReceiveScriptMessage was null.', - ); - final List args = (message as List?)!; - final WKScriptMessageHandler? arg_pigeon_instance = (args[0] as WKScriptMessageHandler?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKScriptMessageHandler.didReceiveScriptMessage was null, expected non-null WKScriptMessageHandler.', - ); - final WKUserContentController? arg_controller = (args[1] as WKUserContentController?); - assert( - arg_controller != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKScriptMessageHandler.didReceiveScriptMessage was null, expected non-null WKUserContentController.', - ); - final WKScriptMessage? arg_message = (args[2] as WKScriptMessage?); - assert( - arg_message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKScriptMessageHandler.didReceiveScriptMessage was null, expected non-null WKScriptMessage.', - ); + final List args = message! as List; + final WKScriptMessageHandler arg_pigeon_instance = args[0]! as WKScriptMessageHandler; + final WKUserContentController arg_controller = args[1]! as WKUserContentController; + final WKScriptMessage arg_message = args[2]! as WKScriptMessage; try { - (didReceiveScriptMessage ?? arg_pigeon_instance!.didReceiveScriptMessage).call( - arg_pigeon_instance!, - arg_controller!, - arg_message!, + (didReceiveScriptMessage ?? arg_pigeon_instance.didReceiveScriptMessage).call( + arg_pigeon_instance, + arg_controller, + arg_message, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -4640,12 +4318,12 @@ class WKScriptMessageHandler extends NSObject { } } -/// Methods for accepting or rejecting navigation changes, and for tracking the -/// progress of navigation requests. +/// A protocol for loading resources with URL schemes that WebKit doesn't +/// handle. /// -/// See https://developer.apple.com/documentation/webkit/wknavigationdelegate. -class WKNavigationDelegate extends NSObject { - factory WKNavigationDelegate({ +/// See https://developer.apple.com/documentation/webkit/wkurlschemehandler. +class WKURLSchemeHandler extends NSObject { + factory WKURLSchemeHandler({ BinaryMessenger? pigeon_binaryMessenger, PigeonInstanceManager? pigeon_instanceManager, void Function( @@ -4655,83 +4333,48 @@ class WKNavigationDelegate extends NSObject { Map? change, )? observeValue, - void Function(WKNavigationDelegate pigeon_instance, WKWebView webView, String? url)? - didFinishNavigation, - void Function(WKNavigationDelegate pigeon_instance, WKWebView webView, String? url)? - didStartProvisionalNavigation, - required Future Function( - WKNavigationDelegate pigeon_instance, - WKWebView webView, - WKNavigationAction navigationAction, - ) - decidePolicyForNavigationAction, - required Future Function( - WKNavigationDelegate pigeon_instance, + required void Function( + WKURLSchemeHandler pigeon_instance, WKWebView webView, - WKNavigationResponse navigationResponse, + WKURLSchemeTask urlSchemeTask, ) - decidePolicyForNavigationResponse, - void Function(WKNavigationDelegate pigeon_instance, WKWebView webView, NSError error)? - didFailNavigation, - void Function(WKNavigationDelegate pigeon_instance, WKWebView webView, NSError error)? - didFailProvisionalNavigation, - void Function(WKNavigationDelegate pigeon_instance, WKWebView webView)? - webViewWebContentProcessDidTerminate, - required Future Function( - WKNavigationDelegate pigeon_instance, + startUrlSchemeTask, + required void Function( + WKURLSchemeHandler pigeon_instance, WKWebView webView, - URLAuthenticationChallenge challenge, + WKURLSchemeTask urlSchemeTask, ) - didReceiveAuthenticationChallenge, + stopUrlSchemeTask, }) { - if (PigeonOverrides.wKNavigationDelegate_new != null) { - return PigeonOverrides.wKNavigationDelegate_new!( + if (PigeonOverrides.wKURLSchemeHandler_new != null) { + return PigeonOverrides.wKURLSchemeHandler_new!( observeValue: observeValue, - didFinishNavigation: didFinishNavigation, - didStartProvisionalNavigation: didStartProvisionalNavigation, - decidePolicyForNavigationAction: decidePolicyForNavigationAction, - decidePolicyForNavigationResponse: decidePolicyForNavigationResponse, - didFailNavigation: didFailNavigation, - didFailProvisionalNavigation: didFailProvisionalNavigation, - webViewWebContentProcessDidTerminate: webViewWebContentProcessDidTerminate, - didReceiveAuthenticationChallenge: didReceiveAuthenticationChallenge, + startUrlSchemeTask: startUrlSchemeTask, + stopUrlSchemeTask: stopUrlSchemeTask, ); } - return WKNavigationDelegate.pigeon_new( + return WKURLSchemeHandler.pigeon_new( pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, observeValue: observeValue, - didFinishNavigation: didFinishNavigation, - didStartProvisionalNavigation: didStartProvisionalNavigation, - decidePolicyForNavigationAction: decidePolicyForNavigationAction, - decidePolicyForNavigationResponse: decidePolicyForNavigationResponse, - didFailNavigation: didFailNavigation, - didFailProvisionalNavigation: didFailProvisionalNavigation, - webViewWebContentProcessDidTerminate: webViewWebContentProcessDidTerminate, - didReceiveAuthenticationChallenge: didReceiveAuthenticationChallenge, + startUrlSchemeTask: startUrlSchemeTask, + stopUrlSchemeTask: stopUrlSchemeTask, ); } @protected - WKNavigationDelegate.pigeon_new({ + WKURLSchemeHandler.pigeon_new({ super.pigeon_binaryMessenger, super.pigeon_instanceManager, super.observeValue, - this.didFinishNavigation, - this.didStartProvisionalNavigation, - required this.decidePolicyForNavigationAction, - required this.decidePolicyForNavigationResponse, - this.didFailNavigation, - this.didFailProvisionalNavigation, - this.webViewWebContentProcessDidTerminate, - required this.didReceiveAuthenticationChallenge, + required this.startUrlSchemeTask, + required this.stopUrlSchemeTask, }) : super.pigeon_detached() { final int pigeonVar_instanceIdentifier = pigeon_instanceManager.addDartCreatedInstance(this); - final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = - _pigeonVar_codecWKNavigationDelegate; + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = _pigeonVar_codecWKURLSchemeHandler; final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; const pigeonVar_channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.pigeon_defaultConstructor'; + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeHandler.pigeon_defaultConstructor'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -4742,43 +4385,28 @@ class WKNavigationDelegate extends NSObject { ]); () async { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); } - /// Constructs [WKNavigationDelegate] without creating the associated native object. + /// Constructs [WKURLSchemeHandler] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to /// create copies for an [PigeonInstanceManager]. @protected - WKNavigationDelegate.pigeon_detached({ + WKURLSchemeHandler.pigeon_detached({ super.pigeon_binaryMessenger, super.pigeon_instanceManager, super.observeValue, - this.didFinishNavigation, - this.didStartProvisionalNavigation, - required this.decidePolicyForNavigationAction, - required this.decidePolicyForNavigationResponse, - this.didFailNavigation, - this.didFailProvisionalNavigation, - this.webViewWebContentProcessDidTerminate, - required this.didReceiveAuthenticationChallenge, + required this.startUrlSchemeTask, + required this.stopUrlSchemeTask, }) : super.pigeon_detached(); - late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecWKNavigationDelegate = + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecWKURLSchemeHandler = _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); - /// Tells the delegate that navigation is complete. + /// Asks the handler to begin loading the data for the specified resource. /// /// For the associated Native object to be automatically garbage collected, /// it is required that the implementation of this `Function` doesn't have a @@ -4788,8 +4416,8 @@ class WKNavigationDelegate extends NSObject { /// /// ```dart /// final WeakReference weakMyVariable = WeakReference(myVariable); - /// final WKNavigationDelegate instance = WKNavigationDelegate( - /// didFinishNavigation: (WKNavigationDelegate pigeon_instance, ...) { + /// final WKURLSchemeHandler instance = WKURLSchemeHandler( + /// startUrlSchemeTask: (WKURLSchemeHandler pigeon_instance, ...) { /// print(weakMyVariable?.target); /// }, /// ); @@ -4797,7 +4425,448 @@ class WKNavigationDelegate extends NSObject { /// /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to /// release the associated Native object manually. - final void Function(WKNavigationDelegate pigeon_instance, WKWebView webView, String? url)? + final void Function( + WKURLSchemeHandler pigeon_instance, + WKWebView webView, + WKURLSchemeTask urlSchemeTask, + ) + startUrlSchemeTask; + + /// Asks the handler to stop loading the data for the specified resource. + /// + /// After this is called, calling methods on the associated + /// [WKURLSchemeTask] is a no-op. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final WKURLSchemeHandler instance = WKURLSchemeHandler( + /// stopUrlSchemeTask: (WKURLSchemeHandler pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function( + WKURLSchemeHandler pigeon_instance, + WKWebView webView, + WKURLSchemeTask urlSchemeTask, + ) + stopUrlSchemeTask; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + void Function( + WKURLSchemeHandler pigeon_instance, + WKWebView webView, + WKURLSchemeTask urlSchemeTask, + )? + startUrlSchemeTask, + void Function( + WKURLSchemeHandler pigeon_instance, + WKWebView webView, + WKURLSchemeTask urlSchemeTask, + )? + stopUrlSchemeTask, + }) { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = _PigeonInternalProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance, + ); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeHandler.startUrlSchemeTask', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); + if (pigeon_clearHandlers) { + pigeonVar_channel.setMessageHandler(null); + } else { + pigeonVar_channel.setMessageHandler((Object? message) async { + final List args = message! as List; + final WKURLSchemeHandler arg_pigeon_instance = args[0]! as WKURLSchemeHandler; + final WKWebView arg_webView = args[1]! as WKWebView; + final WKURLSchemeTask arg_urlSchemeTask = args[2]! as WKURLSchemeTask; + try { + (startUrlSchemeTask ?? arg_pigeon_instance.startUrlSchemeTask).call( + arg_pigeon_instance, + arg_webView, + arg_urlSchemeTask, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString()), + ); + } + }); + } + } + + { + final pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeHandler.stopUrlSchemeTask', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); + if (pigeon_clearHandlers) { + pigeonVar_channel.setMessageHandler(null); + } else { + pigeonVar_channel.setMessageHandler((Object? message) async { + final List args = message! as List; + final WKURLSchemeHandler arg_pigeon_instance = args[0]! as WKURLSchemeHandler; + final WKWebView arg_webView = args[1]! as WKWebView; + final WKURLSchemeTask arg_urlSchemeTask = args[2]! as WKURLSchemeTask; + try { + (stopUrlSchemeTask ?? arg_pigeon_instance.stopUrlSchemeTask).call( + arg_pigeon_instance, + arg_webView, + arg_urlSchemeTask, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString()), + ); + } + }); + } + } + } + + @override + WKURLSchemeHandler pigeon_copy() { + return WKURLSchemeHandler.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + observeValue: observeValue, + startUrlSchemeTask: startUrlSchemeTask, + stopUrlSchemeTask: stopUrlSchemeTask, + ); + } +} + +/// An interface that WebKit uses to request custom resources from your app. +/// +/// See https://developer.apple.com/documentation/webkit/wkurlschemetask. +class WKURLSchemeTask extends NSObject { + /// Constructs [WKURLSchemeTask] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + WKURLSchemeTask.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.request, + super.observeValue, + }) : super.pigeon_detached(); + + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecWKURLSchemeTask = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); + + /// The request object that describes the resource to load. + final URLRequest request; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + WKURLSchemeTask Function(URLRequest request)? pigeon_newInstance, + }) { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = _PigeonInternalProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance, + ); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeTask.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); + if (pigeon_clearHandlers) { + pigeonVar_channel.setMessageHandler(null); + } else { + pigeonVar_channel.setMessageHandler((Object? message) async { + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; + final URLRequest arg_request = args[1]! as URLRequest; + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( + pigeon_newInstance?.call(arg_request) ?? + WKURLSchemeTask.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + request: arg_request, + ), + arg_pigeon_instanceIdentifier, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString()), + ); + } + }); + } + } + } + + /// Informs WebKit that you created a response object for the request. + /// + /// This is a no-op if the task was already stopped with + /// [WKURLSchemeHandler.stopUrlSchemeTask]. + Future didReceiveResponse(URLResponse response) async { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = _pigeonVar_codecWKURLSchemeTask; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const pigeonVar_channelName = + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeTask.didReceiveResponse'; + final pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, response]); + final pigeonVar_replyList = await pigeonVar_sendFuture as List?; + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); + } + + /// Sends some or all of the resource’s data to WebKit. + /// + /// This is a no-op if the task was already stopped with + /// [WKURLSchemeHandler.stopUrlSchemeTask]. + Future didReceiveData(Uint8List data) async { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = _pigeonVar_codecWKURLSchemeTask; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const pigeonVar_channelName = + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeTask.didReceiveData'; + final pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, data]); + final pigeonVar_replyList = await pigeonVar_sendFuture as List?; + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); + } + + /// Informs WebKit that you finished loading the requested data. + /// + /// This is a no-op if the task was already stopped with + /// [WKURLSchemeHandler.stopUrlSchemeTask]. + Future didFinish() async { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = _pigeonVar_codecWKURLSchemeTask; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const pigeonVar_channelName = + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeTask.didFinish'; + final pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); + final pigeonVar_replyList = await pigeonVar_sendFuture as List?; + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); + } + + /// Sends an error to WebKit indicating that the resource load failed. + /// + /// This is a no-op if the task was already stopped with + /// [WKURLSchemeHandler.stopUrlSchemeTask]. + Future didFailWithError(NSError error) async { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = _pigeonVar_codecWKURLSchemeTask; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const pigeonVar_channelName = + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKURLSchemeTask.didFailWithError'; + final pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, error]); + final pigeonVar_replyList = await pigeonVar_sendFuture as List?; + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); + } + + @override + WKURLSchemeTask pigeon_copy() { + return WKURLSchemeTask.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + request: request, + observeValue: observeValue, + ); + } +} + +/// Methods for accepting or rejecting navigation changes, and for tracking the +/// progress of navigation requests. +/// +/// See https://developer.apple.com/documentation/webkit/wknavigationdelegate. +class WKNavigationDelegate extends NSObject { + factory WKNavigationDelegate({ + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + void Function( + NSObject pigeon_instance, + String? keyPath, + NSObject? object, + Map? change, + )? + observeValue, + void Function(WKNavigationDelegate pigeon_instance, WKWebView webView, String? url)? + didFinishNavigation, + void Function(WKNavigationDelegate pigeon_instance, WKWebView webView, String? url)? + didStartProvisionalNavigation, + required Future Function( + WKNavigationDelegate pigeon_instance, + WKWebView webView, + WKNavigationAction navigationAction, + ) + decidePolicyForNavigationAction, + required Future Function( + WKNavigationDelegate pigeon_instance, + WKWebView webView, + WKNavigationResponse navigationResponse, + ) + decidePolicyForNavigationResponse, + void Function(WKNavigationDelegate pigeon_instance, WKWebView webView, NSError error)? + didFailNavigation, + void Function(WKNavigationDelegate pigeon_instance, WKWebView webView, NSError error)? + didFailProvisionalNavigation, + void Function(WKNavigationDelegate pigeon_instance, WKWebView webView)? + webViewWebContentProcessDidTerminate, + required Future Function( + WKNavigationDelegate pigeon_instance, + WKWebView webView, + URLAuthenticationChallenge challenge, + ) + didReceiveAuthenticationChallenge, + }) { + if (PigeonOverrides.wKNavigationDelegate_new != null) { + return PigeonOverrides.wKNavigationDelegate_new!( + observeValue: observeValue, + didFinishNavigation: didFinishNavigation, + didStartProvisionalNavigation: didStartProvisionalNavigation, + decidePolicyForNavigationAction: decidePolicyForNavigationAction, + decidePolicyForNavigationResponse: decidePolicyForNavigationResponse, + didFailNavigation: didFailNavigation, + didFailProvisionalNavigation: didFailProvisionalNavigation, + webViewWebContentProcessDidTerminate: webViewWebContentProcessDidTerminate, + didReceiveAuthenticationChallenge: didReceiveAuthenticationChallenge, + ); + } + return WKNavigationDelegate.pigeon_new( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + observeValue: observeValue, + didFinishNavigation: didFinishNavigation, + didStartProvisionalNavigation: didStartProvisionalNavigation, + decidePolicyForNavigationAction: decidePolicyForNavigationAction, + decidePolicyForNavigationResponse: decidePolicyForNavigationResponse, + didFailNavigation: didFailNavigation, + didFailProvisionalNavigation: didFailProvisionalNavigation, + webViewWebContentProcessDidTerminate: webViewWebContentProcessDidTerminate, + didReceiveAuthenticationChallenge: didReceiveAuthenticationChallenge, + ); + } + + @protected + WKNavigationDelegate.pigeon_new({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + super.observeValue, + this.didFinishNavigation, + this.didStartProvisionalNavigation, + required this.decidePolicyForNavigationAction, + required this.decidePolicyForNavigationResponse, + this.didFailNavigation, + this.didFailProvisionalNavigation, + this.webViewWebContentProcessDidTerminate, + required this.didReceiveAuthenticationChallenge, + }) : super.pigeon_detached() { + final int pigeonVar_instanceIdentifier = pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecWKNavigationDelegate; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const pigeonVar_channelName = + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.pigeon_defaultConstructor'; + final pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([ + pigeonVar_instanceIdentifier, + ]); + () async { + final pigeonVar_replyList = await pigeonVar_sendFuture as List?; + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); + }(); + } + + /// Constructs [WKNavigationDelegate] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + WKNavigationDelegate.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + super.observeValue, + this.didFinishNavigation, + this.didStartProvisionalNavigation, + required this.decidePolicyForNavigationAction, + required this.decidePolicyForNavigationResponse, + this.didFailNavigation, + this.didFailProvisionalNavigation, + this.webViewWebContentProcessDidTerminate, + required this.didReceiveAuthenticationChallenge, + }) : super.pigeon_detached(); + + late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecWKNavigationDelegate = + _PigeonInternalProxyApiBaseCodec(pigeon_instanceManager); + + /// Tells the delegate that navigation is complete. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final WKNavigationDelegate instance = WKNavigationDelegate( + /// didFinishNavigation: (WKNavigationDelegate pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function(WKNavigationDelegate pigeon_instance, WKWebView webView, String? url)? didFinishNavigation; /// Tells the delegate that navigation from the main frame has started. @@ -5016,26 +5085,14 @@ class WKNavigationDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didFinishNavigation was null.', - ); - final List args = (message as List?)!; - final WKNavigationDelegate? arg_pigeon_instance = (args[0] as WKNavigationDelegate?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didFinishNavigation was null, expected non-null WKNavigationDelegate.', - ); - final WKWebView? arg_webView = (args[1] as WKWebView?); - assert( - arg_webView != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didFinishNavigation was null, expected non-null WKWebView.', - ); - final String? arg_url = (args[2] as String?); + final List args = message! as List; + final WKNavigationDelegate arg_pigeon_instance = args[0]! as WKNavigationDelegate; + final WKWebView arg_webView = args[1]! as WKWebView; + final String? arg_url = args[2] as String?; try { - (didFinishNavigation ?? arg_pigeon_instance!.didFinishNavigation)?.call( - arg_pigeon_instance!, - arg_webView!, + (didFinishNavigation ?? arg_pigeon_instance.didFinishNavigation)?.call( + arg_pigeon_instance, + arg_webView, arg_url, ); return wrapResponse(empty: true); @@ -5060,25 +5117,13 @@ class WKNavigationDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didStartProvisionalNavigation was null.', - ); - final List args = (message as List?)!; - final WKNavigationDelegate? arg_pigeon_instance = (args[0] as WKNavigationDelegate?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didStartProvisionalNavigation was null, expected non-null WKNavigationDelegate.', - ); - final WKWebView? arg_webView = (args[1] as WKWebView?); - assert( - arg_webView != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didStartProvisionalNavigation was null, expected non-null WKWebView.', - ); - final String? arg_url = (args[2] as String?); + final List args = message! as List; + final WKNavigationDelegate arg_pigeon_instance = args[0]! as WKNavigationDelegate; + final WKWebView arg_webView = args[1]! as WKWebView; + final String? arg_url = args[2] as String?; try { - (didStartProvisionalNavigation ?? arg_pigeon_instance!.didStartProvisionalNavigation) - ?.call(arg_pigeon_instance!, arg_webView!, arg_url); + (didStartProvisionalNavigation ?? arg_pigeon_instance.didStartProvisionalNavigation) + ?.call(arg_pigeon_instance, arg_webView, arg_url); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); @@ -5101,31 +5146,15 @@ class WKNavigationDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.decidePolicyForNavigationAction was null.', - ); - final List args = (message as List?)!; - final WKNavigationDelegate? arg_pigeon_instance = (args[0] as WKNavigationDelegate?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.decidePolicyForNavigationAction was null, expected non-null WKNavigationDelegate.', - ); - final WKWebView? arg_webView = (args[1] as WKWebView?); - assert( - arg_webView != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.decidePolicyForNavigationAction was null, expected non-null WKWebView.', - ); - final WKNavigationAction? arg_navigationAction = (args[2] as WKNavigationAction?); - assert( - arg_navigationAction != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.decidePolicyForNavigationAction was null, expected non-null WKNavigationAction.', - ); + final List args = message! as List; + final WKNavigationDelegate arg_pigeon_instance = args[0]! as WKNavigationDelegate; + final WKWebView arg_webView = args[1]! as WKWebView; + final WKNavigationAction arg_navigationAction = args[2]! as WKNavigationAction; try { final NavigationActionPolicy output = await (decidePolicyForNavigationAction ?? - arg_pigeon_instance!.decidePolicyForNavigationAction) - .call(arg_pigeon_instance!, arg_webView!, arg_navigationAction!); + arg_pigeon_instance.decidePolicyForNavigationAction) + .call(arg_pigeon_instance, arg_webView, arg_navigationAction); return wrapResponse(result: output); } on PlatformException catch (e) { return wrapResponse(error: e); @@ -5148,31 +5177,15 @@ class WKNavigationDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.decidePolicyForNavigationResponse was null.', - ); - final List args = (message as List?)!; - final WKNavigationDelegate? arg_pigeon_instance = (args[0] as WKNavigationDelegate?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.decidePolicyForNavigationResponse was null, expected non-null WKNavigationDelegate.', - ); - final WKWebView? arg_webView = (args[1] as WKWebView?); - assert( - arg_webView != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.decidePolicyForNavigationResponse was null, expected non-null WKWebView.', - ); - final WKNavigationResponse? arg_navigationResponse = (args[2] as WKNavigationResponse?); - assert( - arg_navigationResponse != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.decidePolicyForNavigationResponse was null, expected non-null WKNavigationResponse.', - ); + final List args = message! as List; + final WKNavigationDelegate arg_pigeon_instance = args[0]! as WKNavigationDelegate; + final WKWebView arg_webView = args[1]! as WKWebView; + final WKNavigationResponse arg_navigationResponse = args[2]! as WKNavigationResponse; try { final NavigationResponsePolicy output = await (decidePolicyForNavigationResponse ?? - arg_pigeon_instance!.decidePolicyForNavigationResponse) - .call(arg_pigeon_instance!, arg_webView!, arg_navigationResponse!); + arg_pigeon_instance.decidePolicyForNavigationResponse) + .call(arg_pigeon_instance, arg_webView, arg_navigationResponse); return wrapResponse(result: output); } on PlatformException catch (e) { return wrapResponse(error: e); @@ -5195,31 +5208,15 @@ class WKNavigationDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didFailNavigation was null.', - ); - final List args = (message as List?)!; - final WKNavigationDelegate? arg_pigeon_instance = (args[0] as WKNavigationDelegate?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didFailNavigation was null, expected non-null WKNavigationDelegate.', - ); - final WKWebView? arg_webView = (args[1] as WKWebView?); - assert( - arg_webView != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didFailNavigation was null, expected non-null WKWebView.', - ); - final NSError? arg_error = (args[2] as NSError?); - assert( - arg_error != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didFailNavigation was null, expected non-null NSError.', - ); + final List args = message! as List; + final WKNavigationDelegate arg_pigeon_instance = args[0]! as WKNavigationDelegate; + final WKWebView arg_webView = args[1]! as WKWebView; + final NSError arg_error = args[2]! as NSError; try { - (didFailNavigation ?? arg_pigeon_instance!.didFailNavigation)?.call( - arg_pigeon_instance!, - arg_webView!, - arg_error!, + (didFailNavigation ?? arg_pigeon_instance.didFailNavigation)?.call( + arg_pigeon_instance, + arg_webView, + arg_error, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -5243,29 +5240,13 @@ class WKNavigationDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didFailProvisionalNavigation was null.', - ); - final List args = (message as List?)!; - final WKNavigationDelegate? arg_pigeon_instance = (args[0] as WKNavigationDelegate?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didFailProvisionalNavigation was null, expected non-null WKNavigationDelegate.', - ); - final WKWebView? arg_webView = (args[1] as WKWebView?); - assert( - arg_webView != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didFailProvisionalNavigation was null, expected non-null WKWebView.', - ); - final NSError? arg_error = (args[2] as NSError?); - assert( - arg_error != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didFailProvisionalNavigation was null, expected non-null NSError.', - ); + final List args = message! as List; + final WKNavigationDelegate arg_pigeon_instance = args[0]! as WKNavigationDelegate; + final WKWebView arg_webView = args[1]! as WKWebView; + final NSError arg_error = args[2]! as NSError; try { - (didFailProvisionalNavigation ?? arg_pigeon_instance!.didFailProvisionalNavigation) - ?.call(arg_pigeon_instance!, arg_webView!, arg_error!); + (didFailProvisionalNavigation ?? arg_pigeon_instance.didFailProvisionalNavigation) + ?.call(arg_pigeon_instance, arg_webView, arg_error); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); @@ -5288,25 +5269,13 @@ class WKNavigationDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.webViewWebContentProcessDidTerminate was null.', - ); - final List args = (message as List?)!; - final WKNavigationDelegate? arg_pigeon_instance = (args[0] as WKNavigationDelegate?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.webViewWebContentProcessDidTerminate was null, expected non-null WKNavigationDelegate.', - ); - final WKWebView? arg_webView = (args[1] as WKWebView?); - assert( - arg_webView != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.webViewWebContentProcessDidTerminate was null, expected non-null WKWebView.', - ); + final List args = message! as List; + final WKNavigationDelegate arg_pigeon_instance = args[0]! as WKNavigationDelegate; + final WKWebView arg_webView = args[1]! as WKWebView; try { (webViewWebContentProcessDidTerminate ?? - arg_pigeon_instance!.webViewWebContentProcessDidTerminate) - ?.call(arg_pigeon_instance!, arg_webView!); + arg_pigeon_instance.webViewWebContentProcessDidTerminate) + ?.call(arg_pigeon_instance, arg_webView); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); @@ -5329,32 +5298,15 @@ class WKNavigationDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didReceiveAuthenticationChallenge was null.', - ); - final List args = (message as List?)!; - final WKNavigationDelegate? arg_pigeon_instance = (args[0] as WKNavigationDelegate?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didReceiveAuthenticationChallenge was null, expected non-null WKNavigationDelegate.', - ); - final WKWebView? arg_webView = (args[1] as WKWebView?); - assert( - arg_webView != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didReceiveAuthenticationChallenge was null, expected non-null WKWebView.', - ); - final URLAuthenticationChallenge? arg_challenge = - (args[2] as URLAuthenticationChallenge?); - assert( - arg_challenge != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegate.didReceiveAuthenticationChallenge was null, expected non-null URLAuthenticationChallenge.', - ); + final List args = message! as List; + final WKNavigationDelegate arg_pigeon_instance = args[0]! as WKNavigationDelegate; + final WKWebView arg_webView = args[1]! as WKWebView; + final URLAuthenticationChallenge arg_challenge = args[2]! as URLAuthenticationChallenge; try { final AuthenticationChallengeResponse output = await (didReceiveAuthenticationChallenge ?? - arg_pigeon_instance!.didReceiveAuthenticationChallenge) - .call(arg_pigeon_instance!, arg_webView!, arg_challenge!); + arg_pigeon_instance.didReceiveAuthenticationChallenge) + .call(arg_pigeon_instance, arg_webView, arg_challenge); return wrapResponse(result: output); } on PlatformException catch (e) { return wrapResponse(error: e); @@ -5434,17 +5386,8 @@ class NSObject extends PigeonInternalProxyApiBaseClass { ]); () async { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); } @@ -5517,16 +5460,8 @@ class NSObject extends PigeonInternalProxyApiBaseClass { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.NSObject.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.NSObject.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -5534,7 +5469,7 @@ class NSObject extends PigeonInternalProxyApiBaseClass { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -5558,23 +5493,15 @@ class NSObject extends PigeonInternalProxyApiBaseClass { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.NSObject.observeValue was null.', - ); - final List args = (message as List?)!; - final NSObject? arg_pigeon_instance = (args[0] as NSObject?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.NSObject.observeValue was null, expected non-null NSObject.', - ); - final String? arg_keyPath = (args[1] as String?); - final NSObject? arg_object = (args[2] as NSObject?); + final List args = message! as List; + final NSObject arg_pigeon_instance = args[0]! as NSObject; + final String? arg_keyPath = args[1] as String?; + final NSObject? arg_object = args[2] as NSObject?; final Map? arg_change = (args[3] as Map?) ?.cast(); try { - (observeValue ?? arg_pigeon_instance!.observeValue)?.call( - arg_pigeon_instance!, + (observeValue ?? arg_pigeon_instance.observeValue)?.call( + arg_pigeon_instance, arg_keyPath, arg_object, arg_change, @@ -5615,17 +5542,8 @@ class NSObject extends PigeonInternalProxyApiBaseClass { options, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Stops the observer object from receiving change notifications for the @@ -5647,17 +5565,8 @@ class NSObject extends PigeonInternalProxyApiBaseClass { keyPath, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } @override @@ -5724,17 +5633,8 @@ class UIViewWKWebView extends UIView implements WKWebView { ]); () async { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); } @@ -5778,16 +5678,8 @@ class UIViewWKWebView extends UIView implements WKWebView { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIViewWKWebView.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIViewWKWebView.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -5795,7 +5687,7 @@ class UIViewWKWebView extends UIView implements WKWebView { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -5833,17 +5725,8 @@ class UIViewWKWebView extends UIView implements WKWebView { pigeonVar_instanceIdentifier, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); return pigeonVar_instance; } @@ -5871,17 +5754,8 @@ class UIViewWKWebView extends UIView implements WKWebView { pigeonVar_instanceIdentifier, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); return pigeonVar_instance; } @@ -5900,17 +5774,8 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, delegate]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The object you use to manage navigation behavior for the web view. @@ -5926,17 +5791,8 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, delegate]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The URL for the current webpage. @@ -5952,17 +5808,13 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return (pigeonVar_replyList[0] as String?); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return pigeonVar_replyValue as String?; } /// An estimate of what fraction of the current navigation has been loaded. @@ -5978,22 +5830,13 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as double?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as double; } /// Loads the web content that the specified URL request object references and @@ -6010,17 +5853,8 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, request]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Loads the contents of the specified HTML string and navigates to it. @@ -6040,17 +5874,8 @@ class UIViewWKWebView extends UIView implements WKWebView { baseUrl, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Loads the web content from the specified file and navigates to it. @@ -6070,17 +5895,8 @@ class UIViewWKWebView extends UIView implements WKWebView { readAccessUrl, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Convenience method to load a Flutter asset. @@ -6096,17 +5912,8 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, key]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// A Boolean value that indicates whether there is a valid back item in the @@ -6123,22 +5930,13 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as bool?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as bool; } /// A Boolean value that indicates whether there is a valid forward item in @@ -6153,24 +5951,15 @@ class UIViewWKWebView extends UIView implements WKWebView { pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); - final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as bool?)!; - } + final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); + final pigeonVar_replyList = await pigeonVar_sendFuture as List?; + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as bool; } /// Navigates to the back item in the back-forward list. @@ -6186,17 +5975,8 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Navigates to the forward item in the back-forward list. @@ -6212,17 +5992,8 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Reloads the current webpage. @@ -6238,17 +6009,8 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The page title. @@ -6264,17 +6026,13 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return (pigeonVar_replyList[0] as String?); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return pigeonVar_replyValue as String?; } /// A Boolean value that indicates whether horizontal swipe gestures trigger @@ -6291,17 +6049,8 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, allow]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The custom user agent string. @@ -6317,17 +6066,8 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, userAgent]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Evaluates the specified JavaScript string. @@ -6346,17 +6086,13 @@ class UIViewWKWebView extends UIView implements WKWebView { javaScriptString, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return pigeonVar_replyList[0]; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return pigeonVar_replyValue; } /// A Boolean value that indicates whether you can inspect the view with @@ -6376,17 +6112,8 @@ class UIViewWKWebView extends UIView implements WKWebView { inspectable, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The custom user agent string. @@ -6402,17 +6129,13 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return (pigeonVar_replyList[0] as String?); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return pigeonVar_replyValue as String?; } /// Whether to allow previews for link destinations and detected data such as @@ -6431,17 +6154,8 @@ class UIViewWKWebView extends UIView implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, allow]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } @override @@ -6508,17 +6222,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { ]); () async { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); } @@ -6559,16 +6264,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.NSViewWKWebView.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.NSViewWKWebView.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -6576,7 +6273,7 @@ class NSViewWKWebView extends NSObject implements WKWebView { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -6614,17 +6311,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { pigeonVar_instanceIdentifier, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); return pigeonVar_instance; } @@ -6643,17 +6331,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, delegate]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The object you use to manage navigation behavior for the web view. @@ -6669,17 +6348,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, delegate]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The URL for the current webpage. @@ -6695,17 +6365,13 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return (pigeonVar_replyList[0] as String?); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return pigeonVar_replyValue as String?; } /// An estimate of what fraction of the current navigation has been loaded. @@ -6721,22 +6387,13 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as double?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as double; } /// Loads the web content that the specified URL request object references and @@ -6753,17 +6410,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, request]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Loads the contents of the specified HTML string and navigates to it. @@ -6783,17 +6431,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { baseUrl, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Loads the web content from the specified file and navigates to it. @@ -6813,17 +6452,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { readAccessUrl, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Convenience method to load a Flutter asset. @@ -6839,17 +6469,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, key]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// A Boolean value that indicates whether there is a valid back item in the @@ -6866,22 +6487,13 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as bool?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as bool; } /// A Boolean value that indicates whether there is a valid forward item in @@ -6898,22 +6510,13 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as bool?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as bool; } /// Navigates to the back item in the back-forward list. @@ -6929,17 +6532,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Navigates to the forward item in the back-forward list. @@ -6955,17 +6549,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Reloads the current webpage. @@ -6981,17 +6566,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The page title. @@ -7007,17 +6583,13 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return (pigeonVar_replyList[0] as String?); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return pigeonVar_replyValue as String?; } /// A Boolean value that indicates whether horizontal swipe gestures trigger @@ -7034,17 +6606,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, allow]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The custom user agent string. @@ -7060,17 +6623,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, userAgent]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Evaluates the specified JavaScript string. @@ -7089,17 +6643,13 @@ class NSViewWKWebView extends NSObject implements WKWebView { javaScriptString, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return pigeonVar_replyList[0]; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return pigeonVar_replyValue; } /// A Boolean value that indicates whether you can inspect the view with @@ -7119,17 +6669,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { inspectable, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// The custom user agent string. @@ -7145,17 +6686,13 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return (pigeonVar_replyList[0] as String?); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return pigeonVar_replyValue as String?; } /// Whether to allow previews for link destinations and detected data such as @@ -7174,17 +6711,8 @@ class NSViewWKWebView extends NSObject implements WKWebView { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, allow]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } @override @@ -7233,16 +6761,8 @@ class WKWebView extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKWebView.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKWebView.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -7250,7 +6770,7 @@ class WKWebView extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -7376,17 +6896,8 @@ class WKUIDelegate extends NSObject { ]); () async { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); } @@ -7603,37 +7114,17 @@ class WKUIDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.onCreateWebView was null.', - ); - final List args = (message as List?)!; - final WKUIDelegate? arg_pigeon_instance = (args[0] as WKUIDelegate?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.onCreateWebView was null, expected non-null WKUIDelegate.', - ); - final WKWebView? arg_webView = (args[1] as WKWebView?); - assert( - arg_webView != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.onCreateWebView was null, expected non-null WKWebView.', - ); - final WKWebViewConfiguration? arg_configuration = (args[2] as WKWebViewConfiguration?); - assert( - arg_configuration != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.onCreateWebView was null, expected non-null WKWebViewConfiguration.', - ); - final WKNavigationAction? arg_navigationAction = (args[3] as WKNavigationAction?); - assert( - arg_navigationAction != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.onCreateWebView was null, expected non-null WKNavigationAction.', - ); + final List args = message! as List; + final WKUIDelegate arg_pigeon_instance = args[0]! as WKUIDelegate; + final WKWebView arg_webView = args[1]! as WKWebView; + final WKWebViewConfiguration arg_configuration = args[2]! as WKWebViewConfiguration; + final WKNavigationAction arg_navigationAction = args[3]! as WKNavigationAction; try { - (onCreateWebView ?? arg_pigeon_instance!.onCreateWebView)?.call( - arg_pigeon_instance!, - arg_webView!, - arg_configuration!, - arg_navigationAction!, + (onCreateWebView ?? arg_pigeon_instance.onCreateWebView)?.call( + arg_pigeon_instance, + arg_webView, + arg_configuration, + arg_navigationAction, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -7657,41 +7148,17 @@ class WKUIDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.requestMediaCapturePermission was null.', - ); - final List args = (message as List?)!; - final WKUIDelegate? arg_pigeon_instance = (args[0] as WKUIDelegate?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.requestMediaCapturePermission was null, expected non-null WKUIDelegate.', - ); - final WKWebView? arg_webView = (args[1] as WKWebView?); - assert( - arg_webView != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.requestMediaCapturePermission was null, expected non-null WKWebView.', - ); - final WKSecurityOrigin? arg_origin = (args[2] as WKSecurityOrigin?); - assert( - arg_origin != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.requestMediaCapturePermission was null, expected non-null WKSecurityOrigin.', - ); - final WKFrameInfo? arg_frame = (args[3] as WKFrameInfo?); - assert( - arg_frame != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.requestMediaCapturePermission was null, expected non-null WKFrameInfo.', - ); - final MediaCaptureType? arg_type = (args[4] as MediaCaptureType?); - assert( - arg_type != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.requestMediaCapturePermission was null, expected non-null MediaCaptureType.', - ); + final List args = message! as List; + final WKUIDelegate arg_pigeon_instance = args[0]! as WKUIDelegate; + final WKWebView arg_webView = args[1]! as WKWebView; + final WKSecurityOrigin arg_origin = args[2]! as WKSecurityOrigin; + final WKFrameInfo arg_frame = args[3]! as WKFrameInfo; + final MediaCaptureType arg_type = args[4]! as MediaCaptureType; try { final PermissionDecision output = await (requestMediaCapturePermission ?? - arg_pigeon_instance!.requestMediaCapturePermission) - .call(arg_pigeon_instance!, arg_webView!, arg_origin!, arg_frame!, arg_type!); + arg_pigeon_instance.requestMediaCapturePermission) + .call(arg_pigeon_instance, arg_webView, arg_origin, arg_frame, arg_type); return wrapResponse(result: output); } on PlatformException catch (e) { return wrapResponse(error: e); @@ -7714,37 +7181,17 @@ class WKUIDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptAlertPanel was null.', - ); - final List args = (message as List?)!; - final WKUIDelegate? arg_pigeon_instance = (args[0] as WKUIDelegate?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptAlertPanel was null, expected non-null WKUIDelegate.', - ); - final WKWebView? arg_webView = (args[1] as WKWebView?); - assert( - arg_webView != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptAlertPanel was null, expected non-null WKWebView.', - ); - final String? arg_message = (args[2] as String?); - assert( - arg_message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptAlertPanel was null, expected non-null String.', - ); - final WKFrameInfo? arg_frame = (args[3] as WKFrameInfo?); - assert( - arg_frame != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptAlertPanel was null, expected non-null WKFrameInfo.', - ); + final List args = message! as List; + final WKUIDelegate arg_pigeon_instance = args[0]! as WKUIDelegate; + final WKWebView arg_webView = args[1]! as WKWebView; + final String arg_message = args[2]! as String; + final WKFrameInfo arg_frame = args[3]! as WKFrameInfo; try { - await (runJavaScriptAlertPanel ?? arg_pigeon_instance!.runJavaScriptAlertPanel)?.call( - arg_pigeon_instance!, - arg_webView!, - arg_message!, - arg_frame!, + await (runJavaScriptAlertPanel ?? arg_pigeon_instance.runJavaScriptAlertPanel)?.call( + arg_pigeon_instance, + arg_webView, + arg_message, + arg_frame, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -7768,35 +7215,15 @@ class WKUIDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptConfirmPanel was null.', - ); - final List args = (message as List?)!; - final WKUIDelegate? arg_pigeon_instance = (args[0] as WKUIDelegate?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptConfirmPanel was null, expected non-null WKUIDelegate.', - ); - final WKWebView? arg_webView = (args[1] as WKWebView?); - assert( - arg_webView != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptConfirmPanel was null, expected non-null WKWebView.', - ); - final String? arg_message = (args[2] as String?); - assert( - arg_message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptConfirmPanel was null, expected non-null String.', - ); - final WKFrameInfo? arg_frame = (args[3] as WKFrameInfo?); - assert( - arg_frame != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptConfirmPanel was null, expected non-null WKFrameInfo.', - ); + final List args = message! as List; + final WKUIDelegate arg_pigeon_instance = args[0]! as WKUIDelegate; + final WKWebView arg_webView = args[1]! as WKWebView; + final String arg_message = args[2]! as String; + final WKFrameInfo arg_frame = args[3]! as WKFrameInfo; try { final bool output = - await (runJavaScriptConfirmPanel ?? arg_pigeon_instance!.runJavaScriptConfirmPanel) - .call(arg_pigeon_instance!, arg_webView!, arg_message!, arg_frame!); + await (runJavaScriptConfirmPanel ?? arg_pigeon_instance.runJavaScriptConfirmPanel) + .call(arg_pigeon_instance, arg_webView, arg_message, arg_frame); return wrapResponse(result: output); } on PlatformException catch (e) { return wrapResponse(error: e); @@ -7819,42 +7246,22 @@ class WKUIDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptTextInputPanel was null.', - ); - final List args = (message as List?)!; - final WKUIDelegate? arg_pigeon_instance = (args[0] as WKUIDelegate?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptTextInputPanel was null, expected non-null WKUIDelegate.', - ); - final WKWebView? arg_webView = (args[1] as WKWebView?); - assert( - arg_webView != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptTextInputPanel was null, expected non-null WKWebView.', - ); - final String? arg_prompt = (args[2] as String?); - assert( - arg_prompt != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptTextInputPanel was null, expected non-null String.', - ); - final String? arg_defaultText = (args[3] as String?); - final WKFrameInfo? arg_frame = (args[4] as WKFrameInfo?); - assert( - arg_frame != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegate.runJavaScriptTextInputPanel was null, expected non-null WKFrameInfo.', - ); + final List args = message! as List; + final WKUIDelegate arg_pigeon_instance = args[0]! as WKUIDelegate; + final WKWebView arg_webView = args[1]! as WKWebView; + final String arg_prompt = args[2]! as String; + final String? arg_defaultText = args[3] as String?; + final WKFrameInfo arg_frame = args[4]! as WKFrameInfo; try { final String? output = await (runJavaScriptTextInputPanel ?? - arg_pigeon_instance!.runJavaScriptTextInputPanel) + arg_pigeon_instance.runJavaScriptTextInputPanel) ?.call( - arg_pigeon_instance!, - arg_webView!, - arg_prompt!, + arg_pigeon_instance, + arg_webView, + arg_prompt, arg_defaultText, - arg_frame!, + arg_frame, ); return wrapResponse(result: output); } on PlatformException catch (e) { @@ -7923,16 +7330,8 @@ class WKHTTPCookieStore extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKHTTPCookieStore.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKHTTPCookieStore.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -7940,7 +7339,7 @@ class WKHTTPCookieStore extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -7969,17 +7368,8 @@ class WKHTTPCookieStore extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, cookie]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } /// Fetches all stored cookies. @@ -7995,22 +7385,13 @@ class WKHTTPCookieStore extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as List?)!.cast(); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return (pigeonVar_replyValue! as List).cast(); } @override @@ -8082,17 +7463,8 @@ class UIScrollViewDelegate extends NSObject { ]); () async { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); } @@ -8169,16 +7541,8 @@ class UIScrollViewDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewDelegate.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewDelegate.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -8186,7 +7550,7 @@ class UIScrollViewDelegate extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -8210,37 +7574,17 @@ class UIScrollViewDelegate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewDelegate.scrollViewDidScroll was null.', - ); - final List args = (message as List?)!; - final UIScrollViewDelegate? arg_pigeon_instance = (args[0] as UIScrollViewDelegate?); - assert( - arg_pigeon_instance != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewDelegate.scrollViewDidScroll was null, expected non-null UIScrollViewDelegate.', - ); - final UIScrollView? arg_scrollView = (args[1] as UIScrollView?); - assert( - arg_scrollView != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewDelegate.scrollViewDidScroll was null, expected non-null UIScrollView.', - ); - final double? arg_x = (args[2] as double?); - assert( - arg_x != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewDelegate.scrollViewDidScroll was null, expected non-null double.', - ); - final double? arg_y = (args[3] as double?); - assert( - arg_y != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewDelegate.scrollViewDidScroll was null, expected non-null double.', - ); + final List args = message! as List; + final UIScrollViewDelegate arg_pigeon_instance = args[0]! as UIScrollViewDelegate; + final UIScrollView arg_scrollView = args[1]! as UIScrollView; + final double arg_x = args[2]! as double; + final double arg_y = args[3]! as double; try { - (scrollViewDidScroll ?? arg_pigeon_instance!.scrollViewDidScroll)?.call( - arg_pigeon_instance!, - arg_scrollView!, - arg_x!, - arg_y!, + (scrollViewDidScroll ?? arg_pigeon_instance.scrollViewDidScroll)?.call( + arg_pigeon_instance, + arg_scrollView, + arg_x, + arg_y, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -8334,17 +7678,8 @@ class URLCredential extends NSObject { ]); () async { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); } @@ -8382,16 +7717,8 @@ class URLCredential extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.URLCredential.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.URLCredential.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -8399,7 +7726,7 @@ class URLCredential extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -8447,22 +7774,13 @@ class URLCredential extends NSObject { persistence, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as URLCredential?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as URLCredential; } /// Creates a URL credential instance for server trust authentication, @@ -8492,22 +7810,13 @@ class URLCredential extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([trust]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as URLCredential?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as URLCredential; } @override @@ -8576,40 +7885,24 @@ class URLProtectionSpace extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.URLProtectionSpace.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.URLProtectionSpace.pigeon_newInstance was null, expected non-null int.', - ); - final String? arg_host = (args[1] as String?); - assert( - arg_host != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.URLProtectionSpace.pigeon_newInstance was null, expected non-null String.', - ); - final int? arg_port = (args[2] as int?); - assert( - arg_port != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.URLProtectionSpace.pigeon_newInstance was null, expected non-null int.', - ); - final String? arg_realm = (args[3] as String?); - final String? arg_authenticationMethod = (args[4] as String?); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; + final String arg_host = args[1]! as String; + final int arg_port = args[2]! as int; + final String? arg_realm = args[3] as String?; + final String? arg_authenticationMethod = args[4] as String?; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( - pigeon_newInstance?.call(arg_host!, arg_port!, arg_realm, arg_authenticationMethod) ?? + pigeon_newInstance?.call(arg_host, arg_port, arg_realm, arg_authenticationMethod) ?? URLProtectionSpace.pigeon_detached( pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, - host: arg_host!, - port: arg_port!, + host: arg_host, + port: arg_port, realm: arg_realm, authenticationMethod: arg_authenticationMethod, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -8637,17 +7930,13 @@ class URLProtectionSpace extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return (pigeonVar_replyList[0] as SecTrust?); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return pigeonVar_replyValue as SecTrust?; } @override @@ -8702,16 +7991,8 @@ class URLAuthenticationChallenge extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.URLAuthenticationChallenge.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.URLAuthenticationChallenge.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -8719,7 +8000,7 @@ class URLAuthenticationChallenge extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -8748,22 +8029,13 @@ class URLAuthenticationChallenge extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as URLProtectionSpace?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as URLProtectionSpace; } @override @@ -8815,16 +8087,8 @@ class URL extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.URL.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.URL.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -8832,7 +8096,7 @@ class URL extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -8860,22 +8124,13 @@ class URL extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as String?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as String; } @override @@ -8927,16 +8182,8 @@ class WKWebpagePreferences extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKWebpagePreferences.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKWebpagePreferences.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -8944,7 +8191,7 @@ class WKWebpagePreferences extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -8974,17 +8221,8 @@ class WKWebpagePreferences extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([this, allow]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); } @override @@ -9044,36 +8282,20 @@ class GetTrustResultResponse extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.GetTrustResultResponse.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.GetTrustResultResponse.pigeon_newInstance was null, expected non-null int.', - ); - final DartSecTrustResultType? arg_result = (args[1] as DartSecTrustResultType?); - assert( - arg_result != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.GetTrustResultResponse.pigeon_newInstance was null, expected non-null DartSecTrustResultType.', - ); - final int? arg_resultCode = (args[2] as int?); - assert( - arg_resultCode != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.GetTrustResultResponse.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; + final DartSecTrustResultType arg_result = args[1]! as DartSecTrustResultType; + final int arg_resultCode = args[2]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( - pigeon_newInstance?.call(arg_result!, arg_resultCode!) ?? + pigeon_newInstance?.call(arg_result, arg_resultCode) ?? GetTrustResultResponse.pigeon_detached( pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, - result: arg_result!, - resultCode: arg_resultCode!, + result: arg_result, + resultCode: arg_resultCode, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -9138,16 +8360,8 @@ class SecTrust extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.SecTrust.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.SecTrust.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -9155,7 +8369,7 @@ class SecTrust extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -9192,22 +8406,13 @@ class SecTrust extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([trust]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as bool?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as bool; } /// Returns an opaque cookie containing exceptions to trust policies that will @@ -9233,17 +8438,13 @@ class SecTrust extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([trust]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return (pigeonVar_replyList[0] as Uint8List?); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return pigeonVar_replyValue as Uint8List?; } /// Sets a list of exceptions that should be ignored when the certificate is @@ -9273,22 +8474,13 @@ class SecTrust extends NSObject { exceptions, ]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as bool?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as bool; } /// Returns the result code from the most recent trust evaluation. @@ -9313,22 +8505,13 @@ class SecTrust extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([trust]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as GetTrustResultResponse?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as GetTrustResultResponse; } /// Certificates used to evaluate trust. @@ -9353,17 +8536,13 @@ class SecTrust extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([trust]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return (pigeonVar_replyList[0] as List?)?.cast(); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); + return (pigeonVar_replyValue as List?)?.cast(); } @override @@ -9414,16 +8593,8 @@ class SecCertificate extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.SecCertificate.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.SecCertificate.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -9431,7 +8602,7 @@ class SecCertificate extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { @@ -9468,22 +8639,13 @@ class SecCertificate extends NSObject { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send([certificate]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as Uint8List?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as Uint8List; } @override @@ -9574,17 +8736,8 @@ class UIColor extends NSObject { ]); () async { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); }(); } @@ -9622,16 +8775,8 @@ class UIColor extends NSObject { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIColor.pigeon_newInstance was null.', - ); - final List args = (message as List?)!; - final int? arg_pigeon_instanceIdentifier = (args[0] as int?); - assert( - arg_pigeon_instanceIdentifier != null, - 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.UIColor.pigeon_newInstance was null, expected non-null int.', - ); + final List args = message! as List; + final int arg_pigeon_instanceIdentifier = args[0]! as int; try { (pigeon_instanceManager ?? PigeonInstanceManager.instance).addHostCreatedInstance( pigeon_newInstance?.call() ?? @@ -9639,7 +8784,7 @@ class UIColor extends NSObject { pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, ), - arg_pigeon_instanceIdentifier!, + arg_pigeon_instanceIdentifier, ); return wrapResponse(empty: true); } on PlatformException catch (e) { diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_webview_controller.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_webview_controller.dart index ffff87a1f43f..df6312beef6d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_webview_controller.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_webview_controller.dart @@ -77,6 +77,7 @@ class WebKitWebViewControllerCreationParams extends PlatformWebViewControllerCre this.allowsInlineMediaPlayback = false, this.limitsNavigationsToAppBoundDomains = false, this.javaScriptCanOpenWindowsAutomatically, + this.urlSchemeHandlers = const {}, }) { _configuration = WKWebViewConfiguration(); @@ -96,6 +97,7 @@ class WebKitWebViewControllerCreationParams extends PlatformWebViewControllerCre if (limitsNavigationsToAppBoundDomains) { _configuration.setLimitsNavigationsToAppBoundDomains(limitsNavigationsToAppBoundDomains); } + urlSchemeHandlers.forEach(_registerUrlSchemeHandler); } /// Constructs a [WebKitWebViewControllerCreationParams] using a @@ -111,15 +113,89 @@ class WebKitWebViewControllerCreationParams extends PlatformWebViewControllerCre bool allowsInlineMediaPlayback = false, bool limitsNavigationsToAppBoundDomains = false, bool? javaScriptCanOpenWindowsAutomatically, + Map urlSchemeHandlers = + const {}, }) : this( mediaTypesRequiringUserAction: mediaTypesRequiringUserAction, allowsInlineMediaPlayback: allowsInlineMediaPlayback, limitsNavigationsToAppBoundDomains: limitsNavigationsToAppBoundDomains, javaScriptCanOpenWindowsAutomatically: javaScriptCanOpenWindowsAutomatically, + urlSchemeHandlers: urlSchemeHandlers, ); late final WKWebViewConfiguration _configuration; + /// The objects that load resources for URL schemes that WebKit doesn't + /// handle, keyed by their URL scheme. + /// + /// Registering a scheme that WebKit already handles (e.g. `http`, `https`, + /// `file`, `data`, `blob`, or `about`) results in a + /// [PlatformException] on the native side. + final Map urlSchemeHandlers; + + // Native handler wrappers, retained so callbacks stay reachable for the + // lifetime of the configuration. + final Map _nativeUrlSchemeHandlers = {}; + + void _registerUrlSchemeHandler(String scheme, WebKitUrlSchemeHandler handler) { + // Tasks that received `start` and have not yet completed or been stopped. + final activeTasks = {}; + // Tasks whose `start` handling is still asynchronously reading the + // request details. + final startingTasks = {}; + // Tasks that received `stop` before the asynchronous `start` handling + // finished reading the request details. + final stoppedBeforeStart = {}; + + final nativeHandler = WKURLSchemeHandler( + startUrlSchemeTask: + (WKURLSchemeHandler instance, WKWebView webView, WKURLSchemeTask task) async { + startingTasks.add(task); + try { + final String? url = await task.request.getUrl(); + final String? httpMethod = await task.request.getHttpMethod(); + + final wrappedTask = WebKitUrlSchemeTask._( + task, + url: url, + httpMethod: httpMethod, + onComplete: () => activeTasks.remove(task), + ); + + if (stoppedBeforeStart.contains(task)) { + // The web view stopped the task while the request details were + // being read; responding is a no-op, so don't deliver the task. + wrappedTask._stopped = true; + return; + } + + activeTasks[task] = wrappedTask; + handler.onStart(wrappedTask); + } finally { + startingTasks.remove(task); + stoppedBeforeStart.remove(task); + } + }, + stopUrlSchemeTask: (WKURLSchemeHandler instance, WKWebView webView, WKURLSchemeTask task) { + final WebKitUrlSchemeTask? wrappedTask = activeTasks.remove(task); + if (wrappedTask == null) { + // Only tasks still reading their request details need the marker; + // for a task that already completed or failed to start, the stop + // notification requires no bookkeeping. + if (startingTasks.contains(task)) { + stoppedBeforeStart.add(task); + } + return; + } + wrappedTask._stopped = true; + handler.onStop?.call(wrappedTask); + }, + ); + + _nativeUrlSchemeHandlers[scheme] = nativeHandler; + _configuration.setURLSchemeHandler(nativeHandler, scheme); + } + /// Media types that require a user gesture to begin playing. /// /// Defaults to include [PlaybackMediaTypes.audio] and @@ -145,6 +221,137 @@ class WebKitWebViewControllerCreationParams extends PlatformWebViewControllerCre final bool? javaScriptCanOpenWindowsAutomatically; } +/// A handler that loads resources for a custom URL scheme in a +/// [WebKitWebViewController]. +/// +/// Set with [WebKitWebViewControllerCreationParams.urlSchemeHandlers]. +/// +/// See https://developer.apple.com/documentation/webkit/wkurlschemehandler. +@immutable +class WebKitUrlSchemeHandler { + /// Constructs a [WebKitUrlSchemeHandler]. + const WebKitUrlSchemeHandler({required this.onStart, this.onStop}); + + /// Invoked when the web view requests a resource with the associated URL + /// scheme. + /// + /// Respond with the [WebKitUrlSchemeTask.didReceiveResponse], + /// [WebKitUrlSchemeTask.didReceiveData], and + /// [WebKitUrlSchemeTask.didFinish]/[WebKitUrlSchemeTask.didFail] methods of + /// the task. + final void Function(WebKitUrlSchemeTask task) onStart; + + /// Invoked when the web view no longer needs the resource of a task + /// previously passed to [onStart]. + /// + /// After this is invoked, responding to the task is a no-op. + final void Function(WebKitUrlSchemeTask task)? onStop; +} + +/// A task associated with loading a resource for a custom URL scheme. +/// +/// Passed to the callbacks of a [WebKitUrlSchemeHandler]. To load the +/// resource, call [didReceiveResponse], then [didReceiveData] one or more +/// times, and finish with [didFinish]. Call [didFail] if the resource could +/// not be loaded. +/// +/// See https://developer.apple.com/documentation/webkit/wkurlschemetask. +class WebKitUrlSchemeTask { + WebKitUrlSchemeTask._( + this._task, { + required this.url, + required this.httpMethod, + required this._onComplete, + }); + + final WKURLSchemeTask _task; + final void Function() _onComplete; + bool _stopped = false; + bool _completed = false; + + /// The URL of the requested resource. + final String? url; + + /// The HTTP method of the request. + final String? httpMethod; + + /// Whether the web view stopped this task with + /// [WebKitUrlSchemeHandler.onStop]. + /// + /// Once true, responding to the task is a no-op. + bool get isStopped => _stopped; + + // Whether the task no longer accepts replies: either the web view stopped + // it, or it was completed with `didFinish`/`didFail`. Native `WKURLSchemeTask` + // methods raise an exception in both cases, so replies become no-ops. + bool get _isClosed => _stopped || _completed; + + /// Creates an HTTP response object for the request and informs the web view + /// about it. + /// + /// Must be called before [didReceiveData]. This is a no-op if the task was + /// stopped or already completed with [didFinish] or [didFail]. + Future didReceiveResponse({ + required int statusCode, + Map headers = const {}, + }) async { + if (_isClosed) { + return; + } + return _task.didReceiveResponse( + HTTPURLResponse(url: url ?? '', statusCode: statusCode, headerFields: headers), + ); + } + + /// Sends some or all of the resource’s data to the web view. + /// + /// May be called multiple times after [didReceiveResponse]. This is a no-op + /// if the task was stopped or already completed with [didFinish] or + /// [didFail]. + Future didReceiveData(Uint8List data) async { + if (_isClosed) { + return; + } + return _task.didReceiveData(data); + } + + /// Informs the web view that the resource finished loading. + /// + /// After this call, responding to the task is a no-op. + Future didFinish() async { + if (_isClosed) { + return; + } + _completed = true; + _onComplete(); + return _task.didFinish(); + } + + /// Informs the web view that the resource failed to load. + /// + /// After this call, responding to the task is a no-op. + Future didFail({ + String domain = 'NSURLErrorDomain', + int code = -1, + String? localizedDescription, + }) async { + if (_isClosed) { + return; + } + _completed = true; + _onComplete(); + return _task.didFailWithError( + NSError( + domain: domain, + code: code, + userInfo: { + if (localizedDescription != null) 'NSLocalizedDescription': localizedDescription, + }, + ), + ); + } +} + /// An implementation of [PlatformWebViewController] with the WebKit api. class WebKitWebViewController extends PlatformWebViewController { /// Constructs a [WebKitWebViewController]. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart index 324d4490c9e1..c9ac00411555 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart @@ -407,6 +407,10 @@ abstract class URLRequest extends NSObject { /// See https://developer.apple.com/documentation/foundation/httpurlresponse. @ProxyApi() abstract class HTTPURLResponse extends URLResponse { + /// Creates an HTTP URL response object with the specified values. + HTTPURLResponse(String url, String? httpVersion, Map? headerFields) + : super(url, null, 0, null); + /// The response’s HTTP status code. late int statusCode; } @@ -416,7 +420,10 @@ abstract class HTTPURLResponse extends URLResponse { /// /// See https://developer.apple.com/documentation/foundation/urlresponse. @ProxyApi() -abstract class URLResponse extends NSObject {} +abstract class URLResponse extends NSObject { + /// Creates a URL response object with the specified values. + URLResponse(String url, String? mimeType, int expectedContentLength, String? textEncodingName); +} /// A script that the web view injects into a webpage. /// @@ -489,6 +496,9 @@ abstract class WKFrameInfo extends NSObject { /// See https://developer.apple.com/documentation/foundation/nserror. @ProxyApi() abstract class NSError extends NSObject { + /// Creates an error object with the specified values. + NSError(); + /// The error code. late int code; @@ -707,6 +717,15 @@ abstract class WKWebViewConfiguration extends NSObject { /// The default preferences to use when loading and rendering content. WKWebpagePreferences getDefaultWebpagePreferences(); + + /// Registers an object to load resources associated with the specified URL + /// scheme. + /// + /// This must be called before the web view is created with this + /// configuration. Registering a scheme that WebKit already handles (e.g. + /// `http`, `https`, `file`, `data`, `blob`, or `about`) results in an + /// exception on the native side. + void setURLSchemeHandler(WKURLSchemeHandler? handler, String urlScheme); } /// An object for managing interactions between JavaScript code and your web @@ -760,6 +779,57 @@ abstract class WKScriptMessageHandler extends NSObject { didReceiveScriptMessage; } +/// A protocol for loading resources with URL schemes that WebKit doesn't +/// handle. +/// +/// See https://developer.apple.com/documentation/webkit/wkurlschemehandler. +@ProxyApi(swiftOptions: SwiftProxyApiOptions(import: 'WebKit')) +abstract class WKURLSchemeHandler extends NSObject { + WKURLSchemeHandler(); + + /// Asks the handler to begin loading the data for the specified resource. + late void Function(WKWebView webView, WKURLSchemeTask urlSchemeTask) startUrlSchemeTask; + + /// Asks the handler to stop loading the data for the specified resource. + /// + /// After this is called, calling methods on the associated + /// [WKURLSchemeTask] is a no-op. + late void Function(WKWebView webView, WKURLSchemeTask urlSchemeTask) stopUrlSchemeTask; +} + +/// An interface that WebKit uses to request custom resources from your app. +/// +/// See https://developer.apple.com/documentation/webkit/wkurlschemetask. +@ProxyApi(swiftOptions: SwiftProxyApiOptions(import: 'WebKit')) +abstract class WKURLSchemeTask extends NSObject { + /// The request object that describes the resource to load. + late URLRequest request; + + /// Informs WebKit that you created a response object for the request. + /// + /// This is a no-op if the task was already stopped with + /// [WKURLSchemeHandler.stopUrlSchemeTask]. + void didReceiveResponse(URLResponse response); + + /// Sends some or all of the resource’s data to WebKit. + /// + /// This is a no-op if the task was already stopped with + /// [WKURLSchemeHandler.stopUrlSchemeTask]. + void didReceiveData(Uint8List data); + + /// Informs WebKit that you finished loading the requested data. + /// + /// This is a no-op if the task was already stopped with + /// [WKURLSchemeHandler.stopUrlSchemeTask]. + void didFinish(); + + /// Sends an error to WebKit indicating that the resource load failed. + /// + /// This is a no-op if the task was already stopped with + /// [WKURLSchemeHandler.stopUrlSchemeTask]. + void didFailWithError(NSError error); +} + /// Methods for accepting or rejecting navigation changes, and for tracking the /// progress of navigation requests. /// diff --git a/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml b/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml index 5a1c07a9c271..482c7309d240 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml +++ b/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml @@ -2,7 +2,7 @@ name: webview_flutter_wkwebview description: A Flutter plugin that provides a WebView widget based on Apple's WKWebView control. repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_wkwebview issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22 -version: 3.26.0 +version: 3.27.0 environment: sdk: ^3.12.0 diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_webview_widget_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_webview_widget_test.mocks.dart index 7d30aa937caf..63fcf88235b5 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_webview_widget_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_webview_widget_test.mocks.dart @@ -1081,6 +1081,15 @@ class MockWKWebViewConfiguration extends _i1.Mock implements _i2.WKWebViewConfig ) as _i4.Future<_i2.WKWebpagePreferences>); + @override + _i4.Future setURLSchemeHandler(_i2.WKURLSchemeHandler? handler, String? urlScheme) => + (super.noSuchMethod( + Invocation.method(#setURLSchemeHandler, [handler, urlScheme]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); + @override _i2.WKWebViewConfiguration pigeon_copy() => (super.noSuchMethod( diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.dart index 757704666dfb..0e1d9d69c7c3 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.dart @@ -18,10 +18,13 @@ import 'package:webview_flutter_wkwebview/webview_flutter_wkwebview.dart'; import 'webkit_webview_controller_test.mocks.dart'; @GenerateNiceMocks(>[ + MockSpec(), + MockSpec(), MockSpec(), MockSpec(), MockSpec(), MockSpec(), + MockSpec(), MockSpec(), MockSpec(), MockSpec(), @@ -1789,6 +1792,325 @@ window.addEventListener("error", function(e) { expect(callbackMessage, 'myMessage'); }); }); + + group('WebKitUrlSchemeHandler', () { + ( + MockWKWebViewConfiguration, + void Function(WKWebView, WKURLSchemeTask), + void Function(WKWebView, WKURLSchemeTask), + ) + createParamsWithSchemeHandler(WebKitUrlSchemeHandler handler) { + final mockConfiguration = MockWKWebViewConfiguration(); + PigeonOverrides.wKWebViewConfiguration_new = + ({ + void Function( + NSObject pigeonInstance, + String? keyPath, + NSObject? object, + Map? change, + )? + observeValue, + }) { + return mockConfiguration; + }; + + late final void Function(WKWebView, WKURLSchemeTask) capturedStart; + late final void Function(WKWebView, WKURLSchemeTask) capturedStop; + PigeonOverrides.wKURLSchemeHandler_new = + ({ + required void Function(WKURLSchemeHandler, WKWebView, WKURLSchemeTask) + startUrlSchemeTask, + required void Function(WKURLSchemeHandler, WKWebView, WKURLSchemeTask) + stopUrlSchemeTask, + void Function( + NSObject pigeonInstance, + String? keyPath, + NSObject? object, + Map? change, + )? + observeValue, + }) { + final instance = WKURLSchemeHandler.pigeon_detached( + startUrlSchemeTask: startUrlSchemeTask, + stopUrlSchemeTask: stopUrlSchemeTask, + ); + capturedStart = (WKWebView webView, WKURLSchemeTask task) => + startUrlSchemeTask(instance, webView, task); + capturedStop = (WKWebView webView, WKURLSchemeTask task) => + stopUrlSchemeTask(instance, webView, task); + return instance; + }; + + WebKitWebViewControllerCreationParams( + urlSchemeHandlers: {'test-scheme': handler}, + ); + + return (mockConfiguration, capturedStart, capturedStop); + } + + MockWKURLSchemeTask createMockTask({ + String? url = 'test-scheme://host/resource', + String? httpMethod = 'GET', + }) { + final mockRequest = MockURLRequest(); + when(mockRequest.getUrl()).thenAnswer((_) async => url); + when(mockRequest.getHttpMethod()).thenAnswer((_) async => httpMethod); + + final mockTask = MockWKURLSchemeTask(); + when(mockTask.request).thenReturn(mockRequest); + return mockTask; + } + + test('handler is registered with the configuration', () { + final handler = WebKitUrlSchemeHandler(onStart: (_) {}); + + final (MockWKWebViewConfiguration mockConfiguration, _, _) = createParamsWithSchemeHandler( + handler, + ); + + verify(mockConfiguration.setURLSchemeHandler(any, 'test-scheme')); + }); + + test('onStart receives the request details', () async { + WebKitUrlSchemeTask? receivedTask; + final handler = WebKitUrlSchemeHandler( + onStart: (WebKitUrlSchemeTask task) => receivedTask = task, + ); + + final (_, void Function(WKWebView, WKURLSchemeTask) startUrlSchemeTask, _) = + createParamsWithSchemeHandler(handler); + + startUrlSchemeTask(MockWKWebView(), createMockTask()); + await pumpEventQueue(); + + expect(receivedTask, isNotNull); + expect(receivedTask!.url, 'test-scheme://host/resource'); + expect(receivedTask!.httpMethod, 'GET'); + expect(receivedTask!.isStopped, isFalse); + }); + + test('responding to a task calls through to the native task', () async { + WebKitUrlSchemeTask? receivedTask; + final handler = WebKitUrlSchemeHandler( + onStart: (WebKitUrlSchemeTask task) => receivedTask = task, + ); + + final (_, void Function(WKWebView, WKURLSchemeTask) startUrlSchemeTask, _) = + createParamsWithSchemeHandler(handler); + + final mockResponse = MockHTTPURLResponse(); + String? responseUrl; + int? responseStatusCode; + Map? responseHeaders; + PigeonOverrides.hTTPURLResponse_new = + ({ + required int statusCode, + required String url, + String? httpVersion, + Map? headerFields, + void Function( + NSObject pigeonInstance, + String? keyPath, + NSObject? object, + Map? change, + )? + observeValue, + }) { + responseUrl = url; + responseStatusCode = statusCode; + responseHeaders = headerFields; + return mockResponse; + }; + + final MockWKURLSchemeTask mockTask = createMockTask(); + startUrlSchemeTask(MockWKWebView(), mockTask); + await pumpEventQueue(); + + final data = Uint8List.fromList([1, 2, 3]); + await receivedTask!.didReceiveResponse( + statusCode: 200, + headers: {'Content-Type': 'image/png'}, + ); + await receivedTask!.didReceiveData(data); + await receivedTask!.didFinish(); + + expect(responseUrl, 'test-scheme://host/resource'); + expect(responseStatusCode, 200); + expect(responseHeaders, {'Content-Type': 'image/png'}); + verifyInOrder([ + mockTask.didReceiveResponse(mockResponse), + mockTask.didReceiveData(data), + mockTask.didFinish(), + ]); + }); + + test('didFail sends an NSError to the native task', () async { + WebKitUrlSchemeTask? receivedTask; + final handler = WebKitUrlSchemeHandler( + onStart: (WebKitUrlSchemeTask task) => receivedTask = task, + ); + + final (_, void Function(WKWebView, WKURLSchemeTask) startUrlSchemeTask, _) = + createParamsWithSchemeHandler(handler); + + final mockError = MockNSError(); + String? errorDomain; + int? errorCode; + Map? errorUserInfo; + PigeonOverrides.nSError_new = + ({ + required int code, + required String domain, + required Map userInfo, + void Function( + NSObject pigeonInstance, + String? keyPath, + NSObject? object, + Map? change, + )? + observeValue, + }) { + errorDomain = domain; + errorCode = code; + errorUserInfo = userInfo; + return mockError; + }; + + final MockWKURLSchemeTask mockTask = createMockTask(); + startUrlSchemeTask(MockWKWebView(), mockTask); + await pumpEventQueue(); + + await receivedTask!.didFail(code: 404, localizedDescription: 'not found'); + + expect(errorDomain, 'NSURLErrorDomain'); + expect(errorCode, 404); + expect(errorUserInfo, {'NSLocalizedDescription': 'not found'}); + verify(mockTask.didFailWithError(mockError)); + }); + + test('onStop marks the task stopped and responses become no-ops', () async { + WebKitUrlSchemeTask? startedTask; + WebKitUrlSchemeTask? stoppedTask; + final handler = WebKitUrlSchemeHandler( + onStart: (WebKitUrlSchemeTask task) => startedTask = task, + onStop: (WebKitUrlSchemeTask task) => stoppedTask = task, + ); + + final ( + _, + void Function(WKWebView, WKURLSchemeTask) startUrlSchemeTask, + void Function(WKWebView, WKURLSchemeTask) stopUrlSchemeTask, + ) = createParamsWithSchemeHandler( + handler, + ); + + final MockWKURLSchemeTask mockTask = createMockTask(); + final mockWebView = MockWKWebView(); + startUrlSchemeTask(mockWebView, mockTask); + await pumpEventQueue(); + + stopUrlSchemeTask(mockWebView, mockTask); + + expect(stoppedTask, same(startedTask)); + expect(startedTask!.isStopped, isTrue); + + await startedTask!.didFinish(); + verifyNever(mockTask.didFinish()); + }); + + test('replies after didFinish are no-ops', () async { + WebKitUrlSchemeTask? startedTask; + final handler = WebKitUrlSchemeHandler( + onStart: (WebKitUrlSchemeTask task) => startedTask = task, + ); + + final (_, void Function(WKWebView, WKURLSchemeTask) startUrlSchemeTask, _) = + createParamsWithSchemeHandler(handler); + + final MockWKURLSchemeTask mockTask = createMockTask(); + startUrlSchemeTask(MockWKWebView(), mockTask); + await pumpEventQueue(); + + await startedTask!.didFinish(); + + await startedTask!.didReceiveResponse(statusCode: 200); + await startedTask!.didReceiveData(Uint8List.fromList([1])); + await startedTask!.didFinish(); + await startedTask!.didFail(); + + verify(mockTask.didFinish()).called(1); + verifyNever(mockTask.didReceiveResponse(any)); + verifyNever(mockTask.didReceiveData(any)); + verifyNever(mockTask.didFailWithError(any)); + // The task was completed, not stopped by the web view. + expect(startedTask!.isStopped, isFalse); + }); + + test('stop after task completion does not invoke onStop', () async { + WebKitUrlSchemeTask? startedTask; + WebKitUrlSchemeTask? stoppedTask; + final handler = WebKitUrlSchemeHandler( + onStart: (WebKitUrlSchemeTask task) => startedTask = task, + onStop: (WebKitUrlSchemeTask task) => stoppedTask = task, + ); + + final ( + _, + void Function(WKWebView, WKURLSchemeTask) startUrlSchemeTask, + void Function(WKWebView, WKURLSchemeTask) stopUrlSchemeTask, + ) = createParamsWithSchemeHandler( + handler, + ); + + final MockWKURLSchemeTask mockTask = createMockTask(); + final mockWebView = MockWKWebView(); + startUrlSchemeTask(mockWebView, mockTask); + await pumpEventQueue(); + + await startedTask!.didFinish(); + + // A stop notification for an already completed task (e.g. the native + // `didFinish` call was still in flight during page teardown) requires + // no bookkeeping and must not reach the handler. + stopUrlSchemeTask(mockWebView, mockTask); + await pumpEventQueue(); + + expect(stoppedTask, isNull); + + // A brand new task with the same native instance must still be + // deliverable afterwards (no stale `stoppedBeforeStart` marker). + startedTask = null; + startUrlSchemeTask(mockWebView, mockTask); + await pumpEventQueue(); + expect(startedTask, isNotNull); + expect(startedTask!.isStopped, isFalse); + }); + + test('a task stopped during request reading is not delivered', () async { + WebKitUrlSchemeTask? startedTask; + final handler = WebKitUrlSchemeHandler( + onStart: (WebKitUrlSchemeTask task) => startedTask = task, + ); + + final ( + _, + void Function(WKWebView, WKURLSchemeTask) startUrlSchemeTask, + void Function(WKWebView, WKURLSchemeTask) stopUrlSchemeTask, + ) = createParamsWithSchemeHandler( + handler, + ); + + final MockWKURLSchemeTask mockTask = createMockTask(); + final mockWebView = MockWKWebView(); + // `stop` arrives while `start` is still asynchronously reading the + // request details. + startUrlSchemeTask(mockWebView, mockTask); + stopUrlSchemeTask(mockWebView, mockTask); + await pumpEventQueue(); + + expect(startedTask, isNull); + }); + }); } // Records the last created instance of itself. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.mocks.dart index 8a159e140fd9..50f5e8368cdf 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.mocks.dart @@ -30,71 +30,223 @@ class _FakePigeonInstanceManager_0 extends _i1.SmartFake implements _i2.PigeonIn : super(parent, parentInvocation); } -class _FakeUIScrollView_1 extends _i1.SmartFake implements _i2.UIScrollView { - _FakeUIScrollView_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); +class _FakeHTTPURLResponse_1 extends _i1.SmartFake implements _i2.HTTPURLResponse { + _FakeHTTPURLResponse_1(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); +} + +class _FakeNSError_2 extends _i1.SmartFake implements _i2.NSError { + _FakeNSError_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeUIScrollViewDelegate_2 extends _i1.SmartFake implements _i2.UIScrollViewDelegate { - _FakeUIScrollViewDelegate_2(Object parent, Invocation parentInvocation) +class _FakeUIScrollView_3 extends _i1.SmartFake implements _i2.UIScrollView { + _FakeUIScrollView_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); +} + +class _FakeUIScrollViewDelegate_4 extends _i1.SmartFake implements _i2.UIScrollViewDelegate { + _FakeUIScrollViewDelegate_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeURL_3 extends _i1.SmartFake implements _i2.URL { - _FakeURL_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); +class _FakeURL_5 extends _i1.SmartFake implements _i2.URL { + _FakeURL_5(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeURLRequest_4 extends _i1.SmartFake implements _i2.URLRequest { - _FakeURLRequest_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); +class _FakeURLRequest_6 extends _i1.SmartFake implements _i2.URLRequest { + _FakeURLRequest_6(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeWKPreferences_5 extends _i1.SmartFake implements _i2.WKPreferences { - _FakeWKPreferences_5(Object parent, Invocation parentInvocation) +class _FakeWKURLSchemeTask_7 extends _i1.SmartFake implements _i2.WKURLSchemeTask { + _FakeWKURLSchemeTask_7(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeWKScriptMessageHandler_6 extends _i1.SmartFake implements _i2.WKScriptMessageHandler { - _FakeWKScriptMessageHandler_6(Object parent, Invocation parentInvocation) +class _FakeWKPreferences_8 extends _i1.SmartFake implements _i2.WKPreferences { + _FakeWKPreferences_8(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeWKUserContentController_7 extends _i1.SmartFake implements _i2.WKUserContentController { - _FakeWKUserContentController_7(Object parent, Invocation parentInvocation) +class _FakeWKScriptMessageHandler_9 extends _i1.SmartFake implements _i2.WKScriptMessageHandler { + _FakeWKScriptMessageHandler_9(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeWKUserScript_8 extends _i1.SmartFake implements _i2.WKUserScript { - _FakeWKUserScript_8(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); +class _FakeWKUserContentController_10 extends _i1.SmartFake implements _i2.WKUserContentController { + _FakeWKUserContentController_10(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } -class _FakeWKWebView_9 extends _i1.SmartFake implements _i2.WKWebView { - _FakeWKWebView_9(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); +class _FakeWKUserScript_11 extends _i1.SmartFake implements _i2.WKUserScript { + _FakeWKUserScript_11(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } -class _FakeWKWebsiteDataStore_10 extends _i1.SmartFake implements _i2.WKWebsiteDataStore { - _FakeWKWebsiteDataStore_10(Object parent, Invocation parentInvocation) +class _FakeWKWebView_12 extends _i1.SmartFake implements _i2.WKWebView { + _FakeWKWebView_12(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); +} + +class _FakeWKWebsiteDataStore_13 extends _i1.SmartFake implements _i2.WKWebsiteDataStore { + _FakeWKWebsiteDataStore_13(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeWKWebpagePreferences_11 extends _i1.SmartFake implements _i2.WKWebpagePreferences { - _FakeWKWebpagePreferences_11(Object parent, Invocation parentInvocation) +class _FakeWKWebpagePreferences_14 extends _i1.SmartFake implements _i2.WKWebpagePreferences { + _FakeWKWebpagePreferences_14(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeWKWebViewConfiguration_12 extends _i1.SmartFake implements _i2.WKWebViewConfiguration { - _FakeWKWebViewConfiguration_12(Object parent, Invocation parentInvocation) +class _FakeWKWebViewConfiguration_15 extends _i1.SmartFake implements _i2.WKWebViewConfiguration { + _FakeWKWebViewConfiguration_15(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeUIViewWKWebView_13 extends _i1.SmartFake implements _i2.UIViewWKWebView { - _FakeUIViewWKWebView_13(Object parent, Invocation parentInvocation) +class _FakeUIViewWKWebView_16 extends _i1.SmartFake implements _i2.UIViewWKWebView { + _FakeUIViewWKWebView_16(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeWKHTTPCookieStore_14 extends _i1.SmartFake implements _i2.WKHTTPCookieStore { - _FakeWKHTTPCookieStore_14(Object parent, Invocation parentInvocation) +class _FakeWKHTTPCookieStore_17 extends _i1.SmartFake implements _i2.WKHTTPCookieStore { + _FakeWKHTTPCookieStore_17(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } +/// A class which mocks [HTTPURLResponse]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockHTTPURLResponse extends _i1.Mock implements _i2.HTTPURLResponse { + @override + int get statusCode => + (super.noSuchMethod( + Invocation.getter(#statusCode), + returnValue: 0, + returnValueForMissingStub: 0, + ) + as int); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => + (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) + as _i2.PigeonInstanceManager); + + @override + _i2.HTTPURLResponse pigeon_copy() => + (super.noSuchMethod( + Invocation.method(#pigeon_copy, []), + returnValue: _FakeHTTPURLResponse_1(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeHTTPURLResponse_1( + this, + Invocation.method(#pigeon_copy, []), + ), + ) + as _i2.HTTPURLResponse); + + @override + _i3.Future addObserver( + _i2.NSObject? observer, + String? keyPath, + List<_i2.KeyValueObservingOptions>? options, + ) => + (super.noSuchMethod( + Invocation.method(#addObserver, [observer, keyPath, options]), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) + as _i3.Future); + + @override + _i3.Future removeObserver(_i2.NSObject? observer, String? keyPath) => + (super.noSuchMethod( + Invocation.method(#removeObserver, [observer, keyPath]), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) + as _i3.Future); +} + +/// A class which mocks [NSError]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockNSError extends _i1.Mock implements _i2.NSError { + @override + int get code => + (super.noSuchMethod(Invocation.getter(#code), returnValue: 0, returnValueForMissingStub: 0) + as int); + + @override + String get domain => + (super.noSuchMethod( + Invocation.getter(#domain), + returnValue: _i4.dummyValue(this, Invocation.getter(#domain)), + returnValueForMissingStub: _i4.dummyValue(this, Invocation.getter(#domain)), + ) + as String); + + @override + Map get userInfo => + (super.noSuchMethod( + Invocation.getter(#userInfo), + returnValue: {}, + returnValueForMissingStub: {}, + ) + as Map); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => + (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) + as _i2.PigeonInstanceManager); + + @override + _i2.NSError pigeon_copy() => + (super.noSuchMethod( + Invocation.method(#pigeon_copy, []), + returnValue: _FakeNSError_2(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeNSError_2(this, Invocation.method(#pigeon_copy, [])), + ) + as _i2.NSError); + + @override + _i3.Future addObserver( + _i2.NSObject? observer, + String? keyPath, + List<_i2.KeyValueObservingOptions>? options, + ) => + (super.noSuchMethod( + Invocation.method(#addObserver, [observer, keyPath, options]), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) + as _i3.Future); + + @override + _i3.Future removeObserver(_i2.NSObject? observer, String? keyPath) => + (super.noSuchMethod( + Invocation.method(#removeObserver, [observer, keyPath]), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) + as _i3.Future); +} + /// A class which mocks [UIScrollView]. /// /// See the documentation for Mockito's code generation for more information. @@ -217,8 +369,8 @@ class MockUIScrollView extends _i1.Mock implements _i2.UIScrollView { _i2.UIScrollView pigeon_copy() => (super.noSuchMethod( Invocation.method(#pigeon_copy, []), - returnValue: _FakeUIScrollView_1(this, Invocation.method(#pigeon_copy, [])), - returnValueForMissingStub: _FakeUIScrollView_1( + returnValue: _FakeUIScrollView_3(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeUIScrollView_3( this, Invocation.method(#pigeon_copy, []), ), @@ -289,8 +441,8 @@ class MockUIScrollViewDelegate extends _i1.Mock implements _i2.UIScrollViewDeleg _i2.UIScrollViewDelegate pigeon_copy() => (super.noSuchMethod( Invocation.method(#pigeon_copy, []), - returnValue: _FakeUIScrollViewDelegate_2(this, Invocation.method(#pigeon_copy, [])), - returnValueForMissingStub: _FakeUIScrollViewDelegate_2( + returnValue: _FakeUIScrollViewDelegate_4(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeUIScrollViewDelegate_4( this, Invocation.method(#pigeon_copy, []), ), @@ -356,8 +508,8 @@ class MockURL extends _i1.Mock implements _i2.URL { _i2.URL pigeon_copy() => (super.noSuchMethod( Invocation.method(#pigeon_copy, []), - returnValue: _FakeURL_3(this, Invocation.method(#pigeon_copy, [])), - returnValueForMissingStub: _FakeURL_3(this, Invocation.method(#pigeon_copy, [])), + returnValue: _FakeURL_5(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeURL_5(this, Invocation.method(#pigeon_copy, [])), ) as _i2.URL); @@ -470,8 +622,8 @@ class MockURLRequest extends _i1.Mock implements _i2.URLRequest { _i2.URLRequest pigeon_copy() => (super.noSuchMethod( Invocation.method(#pigeon_copy, []), - returnValue: _FakeURLRequest_4(this, Invocation.method(#pigeon_copy, [])), - returnValueForMissingStub: _FakeURLRequest_4(this, Invocation.method(#pigeon_copy, [])), + returnValue: _FakeURLRequest_6(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeURLRequest_6(this, Invocation.method(#pigeon_copy, [])), ) as _i2.URLRequest); @@ -498,6 +650,105 @@ class MockURLRequest extends _i1.Mock implements _i2.URLRequest { as _i3.Future); } +/// A class which mocks [WKURLSchemeTask]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockWKURLSchemeTask extends _i1.Mock implements _i2.WKURLSchemeTask { + @override + _i2.URLRequest get request => + (super.noSuchMethod( + Invocation.getter(#request), + returnValue: _FakeURLRequest_6(this, Invocation.getter(#request)), + returnValueForMissingStub: _FakeURLRequest_6(this, Invocation.getter(#request)), + ) + as _i2.URLRequest); + + @override + _i2.PigeonInstanceManager get pigeon_instanceManager => + (super.noSuchMethod( + Invocation.getter(#pigeon_instanceManager), + returnValue: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + returnValueForMissingStub: _FakePigeonInstanceManager_0( + this, + Invocation.getter(#pigeon_instanceManager), + ), + ) + as _i2.PigeonInstanceManager); + + @override + _i3.Future didReceiveResponse(_i2.URLResponse? response) => + (super.noSuchMethod( + Invocation.method(#didReceiveResponse, [response]), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) + as _i3.Future); + + @override + _i3.Future didReceiveData(_i5.Uint8List? data) => + (super.noSuchMethod( + Invocation.method(#didReceiveData, [data]), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) + as _i3.Future); + + @override + _i3.Future didFinish() => + (super.noSuchMethod( + Invocation.method(#didFinish, []), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) + as _i3.Future); + + @override + _i3.Future didFailWithError(_i2.NSError? error) => + (super.noSuchMethod( + Invocation.method(#didFailWithError, [error]), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) + as _i3.Future); + + @override + _i2.WKURLSchemeTask pigeon_copy() => + (super.noSuchMethod( + Invocation.method(#pigeon_copy, []), + returnValue: _FakeWKURLSchemeTask_7(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeWKURLSchemeTask_7( + this, + Invocation.method(#pigeon_copy, []), + ), + ) + as _i2.WKURLSchemeTask); + + @override + _i3.Future addObserver( + _i2.NSObject? observer, + String? keyPath, + List<_i2.KeyValueObservingOptions>? options, + ) => + (super.noSuchMethod( + Invocation.method(#addObserver, [observer, keyPath, options]), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) + as _i3.Future); + + @override + _i3.Future removeObserver(_i2.NSObject? observer, String? keyPath) => + (super.noSuchMethod( + Invocation.method(#removeObserver, [observer, keyPath]), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) + as _i3.Future); +} + /// A class which mocks [WKPreferences]. /// /// See the documentation for Mockito's code generation for more information. @@ -539,8 +790,8 @@ class MockWKPreferences extends _i1.Mock implements _i2.WKPreferences { _i2.WKPreferences pigeon_copy() => (super.noSuchMethod( Invocation.method(#pigeon_copy, []), - returnValue: _FakeWKPreferences_5(this, Invocation.method(#pigeon_copy, [])), - returnValueForMissingStub: _FakeWKPreferences_5( + returnValue: _FakeWKPreferences_8(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeWKPreferences_8( this, Invocation.method(#pigeon_copy, []), ), @@ -617,8 +868,8 @@ class MockWKScriptMessageHandler extends _i1.Mock implements _i2.WKScriptMessage _i2.WKScriptMessageHandler pigeon_copy() => (super.noSuchMethod( Invocation.method(#pigeon_copy, []), - returnValue: _FakeWKScriptMessageHandler_6(this, Invocation.method(#pigeon_copy, [])), - returnValueForMissingStub: _FakeWKScriptMessageHandler_6( + returnValue: _FakeWKScriptMessageHandler_9(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeWKScriptMessageHandler_9( this, Invocation.method(#pigeon_copy, []), ), @@ -716,8 +967,8 @@ class MockWKUserContentController extends _i1.Mock implements _i2.WKUserContentC _i2.WKUserContentController pigeon_copy() => (super.noSuchMethod( Invocation.method(#pigeon_copy, []), - returnValue: _FakeWKUserContentController_7(this, Invocation.method(#pigeon_copy, [])), - returnValueForMissingStub: _FakeWKUserContentController_7( + returnValue: _FakeWKUserContentController_10(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeWKUserContentController_10( this, Invocation.method(#pigeon_copy, []), ), @@ -797,8 +1048,8 @@ class MockWKUserScript extends _i1.Mock implements _i2.WKUserScript { _i2.WKUserScript pigeon_copy() => (super.noSuchMethod( Invocation.method(#pigeon_copy, []), - returnValue: _FakeWKUserScript_8(this, Invocation.method(#pigeon_copy, [])), - returnValueForMissingStub: _FakeWKUserScript_8( + returnValue: _FakeWKUserScript_11(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeWKUserScript_11( this, Invocation.method(#pigeon_copy, []), ), @@ -851,8 +1102,8 @@ class MockWKWebView extends _i1.Mock implements _i2.WKWebView { _i2.WKWebView pigeon_copy() => (super.noSuchMethod( Invocation.method(#pigeon_copy, []), - returnValue: _FakeWKWebView_9(this, Invocation.method(#pigeon_copy, [])), - returnValueForMissingStub: _FakeWKWebView_9(this, Invocation.method(#pigeon_copy, [])), + returnValue: _FakeWKWebView_12(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeWKWebView_12(this, Invocation.method(#pigeon_copy, [])), ) as _i2.WKWebView); @@ -912,13 +1163,13 @@ class MockWKWebViewConfiguration extends _i1.Mock implements _i2.WKWebViewConfig (super.noSuchMethod( Invocation.method(#getUserContentController, []), returnValue: _i3.Future<_i2.WKUserContentController>.value( - _FakeWKUserContentController_7( + _FakeWKUserContentController_10( this, Invocation.method(#getUserContentController, []), ), ), returnValueForMissingStub: _i3.Future<_i2.WKUserContentController>.value( - _FakeWKUserContentController_7( + _FakeWKUserContentController_10( this, Invocation.method(#getUserContentController, []), ), @@ -940,10 +1191,10 @@ class MockWKWebViewConfiguration extends _i1.Mock implements _i2.WKWebViewConfig (super.noSuchMethod( Invocation.method(#getWebsiteDataStore, []), returnValue: _i3.Future<_i2.WKWebsiteDataStore>.value( - _FakeWKWebsiteDataStore_10(this, Invocation.method(#getWebsiteDataStore, [])), + _FakeWKWebsiteDataStore_13(this, Invocation.method(#getWebsiteDataStore, [])), ), returnValueForMissingStub: _i3.Future<_i2.WKWebsiteDataStore>.value( - _FakeWKWebsiteDataStore_10(this, Invocation.method(#getWebsiteDataStore, [])), + _FakeWKWebsiteDataStore_13(this, Invocation.method(#getWebsiteDataStore, [])), ), ) as _i3.Future<_i2.WKWebsiteDataStore>); @@ -962,10 +1213,10 @@ class MockWKWebViewConfiguration extends _i1.Mock implements _i2.WKWebViewConfig (super.noSuchMethod( Invocation.method(#getPreferences, []), returnValue: _i3.Future<_i2.WKPreferences>.value( - _FakeWKPreferences_5(this, Invocation.method(#getPreferences, [])), + _FakeWKPreferences_8(this, Invocation.method(#getPreferences, [])), ), returnValueForMissingStub: _i3.Future<_i2.WKPreferences>.value( - _FakeWKPreferences_5(this, Invocation.method(#getPreferences, [])), + _FakeWKPreferences_8(this, Invocation.method(#getPreferences, [])), ), ) as _i3.Future<_i2.WKPreferences>); @@ -1002,13 +1253,13 @@ class MockWKWebViewConfiguration extends _i1.Mock implements _i2.WKWebViewConfig (super.noSuchMethod( Invocation.method(#getDefaultWebpagePreferences, []), returnValue: _i3.Future<_i2.WKWebpagePreferences>.value( - _FakeWKWebpagePreferences_11( + _FakeWKWebpagePreferences_14( this, Invocation.method(#getDefaultWebpagePreferences, []), ), ), returnValueForMissingStub: _i3.Future<_i2.WKWebpagePreferences>.value( - _FakeWKWebpagePreferences_11( + _FakeWKWebpagePreferences_14( this, Invocation.method(#getDefaultWebpagePreferences, []), ), @@ -1016,12 +1267,21 @@ class MockWKWebViewConfiguration extends _i1.Mock implements _i2.WKWebViewConfig ) as _i3.Future<_i2.WKWebpagePreferences>); + @override + _i3.Future setURLSchemeHandler(_i2.WKURLSchemeHandler? handler, String? urlScheme) => + (super.noSuchMethod( + Invocation.method(#setURLSchemeHandler, [handler, urlScheme]), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) + as _i3.Future); + @override _i2.WKWebViewConfiguration pigeon_copy() => (super.noSuchMethod( Invocation.method(#pigeon_copy, []), - returnValue: _FakeWKWebViewConfiguration_12(this, Invocation.method(#pigeon_copy, [])), - returnValueForMissingStub: _FakeWKWebViewConfiguration_12( + returnValue: _FakeWKWebViewConfiguration_15(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeWKWebViewConfiguration_15( this, Invocation.method(#pigeon_copy, []), ), @@ -1083,8 +1343,8 @@ class MockWKWebpagePreferences extends _i1.Mock implements _i2.WKWebpagePreferen _i2.WKWebpagePreferences pigeon_copy() => (super.noSuchMethod( Invocation.method(#pigeon_copy, []), - returnValue: _FakeWKWebpagePreferences_11(this, Invocation.method(#pigeon_copy, [])), - returnValueForMissingStub: _FakeWKWebpagePreferences_11( + returnValue: _FakeWKWebpagePreferences_14(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeWKWebpagePreferences_14( this, Invocation.method(#pigeon_copy, []), ), @@ -1122,8 +1382,8 @@ class MockUIViewWKWebView extends _i1.Mock implements _i2.UIViewWKWebView { _i2.WKWebViewConfiguration get configuration => (super.noSuchMethod( Invocation.getter(#configuration), - returnValue: _FakeWKWebViewConfiguration_12(this, Invocation.getter(#configuration)), - returnValueForMissingStub: _FakeWKWebViewConfiguration_12( + returnValue: _FakeWKWebViewConfiguration_15(this, Invocation.getter(#configuration)), + returnValueForMissingStub: _FakeWKWebViewConfiguration_15( this, Invocation.getter(#configuration), ), @@ -1134,8 +1394,8 @@ class MockUIViewWKWebView extends _i1.Mock implements _i2.UIViewWKWebView { _i2.UIScrollView get scrollView => (super.noSuchMethod( Invocation.getter(#scrollView), - returnValue: _FakeUIScrollView_1(this, Invocation.getter(#scrollView)), - returnValueForMissingStub: _FakeUIScrollView_1(this, Invocation.getter(#scrollView)), + returnValue: _FakeUIScrollView_3(this, Invocation.getter(#scrollView)), + returnValueForMissingStub: _FakeUIScrollView_3(this, Invocation.getter(#scrollView)), ) as _i2.UIScrollView); @@ -1158,11 +1418,11 @@ class MockUIViewWKWebView extends _i1.Mock implements _i2.UIViewWKWebView { _i2.WKWebViewConfiguration pigeonVar_configuration() => (super.noSuchMethod( Invocation.method(#pigeonVar_configuration, []), - returnValue: _FakeWKWebViewConfiguration_12( + returnValue: _FakeWKWebViewConfiguration_15( this, Invocation.method(#pigeonVar_configuration, []), ), - returnValueForMissingStub: _FakeWKWebViewConfiguration_12( + returnValueForMissingStub: _FakeWKWebViewConfiguration_15( this, Invocation.method(#pigeonVar_configuration, []), ), @@ -1173,8 +1433,8 @@ class MockUIViewWKWebView extends _i1.Mock implements _i2.UIViewWKWebView { _i2.UIScrollView pigeonVar_scrollView() => (super.noSuchMethod( Invocation.method(#pigeonVar_scrollView, []), - returnValue: _FakeUIScrollView_1(this, Invocation.method(#pigeonVar_scrollView, [])), - returnValueForMissingStub: _FakeUIScrollView_1( + returnValue: _FakeUIScrollView_3(this, Invocation.method(#pigeonVar_scrollView, [])), + returnValueForMissingStub: _FakeUIScrollView_3( this, Invocation.method(#pigeonVar_scrollView, []), ), @@ -1365,8 +1625,8 @@ class MockUIViewWKWebView extends _i1.Mock implements _i2.UIViewWKWebView { _i2.UIViewWKWebView pigeon_copy() => (super.noSuchMethod( Invocation.method(#pigeon_copy, []), - returnValue: _FakeUIViewWKWebView_13(this, Invocation.method(#pigeon_copy, [])), - returnValueForMissingStub: _FakeUIViewWKWebView_13( + returnValue: _FakeUIViewWKWebView_16(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeUIViewWKWebView_16( this, Invocation.method(#pigeon_copy, []), ), @@ -1422,8 +1682,8 @@ class MockWKWebsiteDataStore extends _i1.Mock implements _i2.WKWebsiteDataStore _i2.WKHTTPCookieStore get httpCookieStore => (super.noSuchMethod( Invocation.getter(#httpCookieStore), - returnValue: _FakeWKHTTPCookieStore_14(this, Invocation.getter(#httpCookieStore)), - returnValueForMissingStub: _FakeWKHTTPCookieStore_14( + returnValue: _FakeWKHTTPCookieStore_17(this, Invocation.getter(#httpCookieStore)), + returnValueForMissingStub: _FakeWKHTTPCookieStore_17( this, Invocation.getter(#httpCookieStore), ), @@ -1449,11 +1709,11 @@ class MockWKWebsiteDataStore extends _i1.Mock implements _i2.WKWebsiteDataStore _i2.WKHTTPCookieStore pigeonVar_httpCookieStore() => (super.noSuchMethod( Invocation.method(#pigeonVar_httpCookieStore, []), - returnValue: _FakeWKHTTPCookieStore_14( + returnValue: _FakeWKHTTPCookieStore_17( this, Invocation.method(#pigeonVar_httpCookieStore, []), ), - returnValueForMissingStub: _FakeWKHTTPCookieStore_14( + returnValueForMissingStub: _FakeWKHTTPCookieStore_17( this, Invocation.method(#pigeonVar_httpCookieStore, []), ), @@ -1476,8 +1736,8 @@ class MockWKWebsiteDataStore extends _i1.Mock implements _i2.WKWebsiteDataStore _i2.WKWebsiteDataStore pigeon_copy() => (super.noSuchMethod( Invocation.method(#pigeon_copy, []), - returnValue: _FakeWKWebsiteDataStore_10(this, Invocation.method(#pigeon_copy, [])), - returnValueForMissingStub: _FakeWKWebsiteDataStore_10( + returnValue: _FakeWKWebsiteDataStore_13(this, Invocation.method(#pigeon_copy, [])), + returnValueForMissingStub: _FakeWKWebsiteDataStore_13( this, Invocation.method(#pigeon_copy, []), ), diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_widget_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_widget_test.mocks.dart index fe14e9d5f96b..0c3a295a1a9a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_widget_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_widget_test.mocks.dart @@ -274,6 +274,15 @@ class MockWKWebViewConfiguration extends _i1.Mock implements _i2.WKWebViewConfig ) as _i3.Future<_i2.WKWebpagePreferences>); + @override + _i3.Future setURLSchemeHandler(_i2.WKURLSchemeHandler? handler, String? urlScheme) => + (super.noSuchMethod( + Invocation.method(#setURLSchemeHandler, [handler, urlScheme]), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) + as _i3.Future); + @override _i2.WKWebViewConfiguration pigeon_copy() => (super.noSuchMethod(