diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/find_interaction/FindInteractionController.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/find_interaction/FindInteractionController.ets index b040118f047c03e64ce4d48cdc54069ec49cd9e0..936b048feeb21a02cd8259b69a67671c7e2c9186 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/find_interaction/FindInteractionController.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/find_interaction/FindInteractionController.ets @@ -68,6 +68,9 @@ export class FindInteractionController implements Disposable { } dispose(): void { - throw new Error('Method not implemented.'); + if(this.channelDelegate != null){ + this.channelDelegate.dispose(); + this.channelDelegate = null; + } } } \ No newline at end of file diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets index c533bee1c5e43cfed5b9bb7d1605d181d1ac6808..0bb2006634a7b4474684e2bb4a5a447de9a261b0 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets @@ -74,7 +74,7 @@ export default class InAppWebView implements InAppWebViewInterface { public id: number; public windowId: number | null | undefined; public inAppWebViewClient: InAppWebViewClient | null = null; - public channelDelegate: WebViewChannelDelegate; + public channelDelegate: WebViewChannelDelegate | null = null; private javaScriptBridgeInterface: JavaScriptBridgeInterface | null = null; public customSettings: InAppWebViewSettings; public isLoading: boolean = false @@ -695,6 +695,26 @@ export default class InAppWebView implements InAppWebViewInterface { this.webViewAssetLoaderExt.dispose(); this.webViewAssetLoaderExt = null; } + if(this.controller){ + this.controller.deleteJavaScriptRegister(JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME); + this.controller.refresh(); + } + if(this.javaScriptBridgeInterface != null){ + this.javaScriptBridgeInterface.dispose(); + this.javaScriptBridgeInterface = null; + } + if(this.findInteractionController != null){ + this.findInteractionController.dispose(); + this.findInteractionController = null; + } + if(this.pullToRefreshLayout != null){ + this.pullToRefreshLayout.dispose(); + this.pullToRefreshLayout = null; + } + if(this.channelDelegate != null){ + this.channelDelegate.dispose(); + this.channelDelegate = null; + } } getUrl(): string { diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebViewClient.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebViewClient.ets index 72ed83e5544ccf4f4836f054ddb0d5f3ca370048..23e24258e19ceebed666810adbba760489f28da1 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebViewClient.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebViewClient.ets @@ -151,7 +151,7 @@ export default class InAppWebViewClient { URLUtil.guessFileName(event.url, event.contentDisposition, event.mimetype), null ); - this.inAppWebView.channelDelegate.onDownloadStartRequest(downloadStartRequest) + this.inAppWebView.channelDelegate?.onDownloadStartRequest(downloadStartRequest) } } onErrorReceive = (event: Any) => {