pichillilorenzo / flutter_inappwebview

A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.
https://inappwebview.dev
Apache License 2.0
3.31k stars 1.64k forks source link

getUrl() throws an exception in flutter web app #2199

Open hossameldinmi opened 5 months ago

hossameldinmi commented 5 months ago

Environment

Technology Version
Flutter version 3.22.2
Plugin version 6.0.0
Android version
iOS version
macOS version
Xcode version 15.4
Google Chrome version 126.0.6478.63

Device information: Macbook pro 2021, M1 Pro,

Description

Launch a flutter web app in chrome instance, I am using _controller.getUrl() method to get the current url of the frame Expected behavior: get the current url Current behavior: it gives null after throwing internal exception

Steps to reproduce

  1. Initiate webview component
  2. use _controller.getUrl(); method

Stacktrace/Logcat

TypeError: Cannot read properties of null (reading 'src') assets/packages/flutter_inappwebview_web/assets/web/web_support.js 366:34 getUrl dart-sdk/lib/_internal/js_dev_runtime/patch/js_patch.dart 145:53 callMethod packages/flutter_inappwebview_web/web/in_app_web_view_web_element.dart 249:21 [_callMethod] packages/flutter_inappwebview_web/web/in_app_web_view_web_element.dart 343:19 getUrl dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async packages/flutter_inappwebview_web/web/in_app_web_view_web_element.dart 342:25 getUrl packages/flutter_inappwebview_web/web/in_app_web_view_web_element.dart 115:22 handleMethodCall dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async packages/flutter_inappwebview_web/web/in_app_web_view_web_element.dart 67:35 handleMethodCall packages/flutter_inappwebview_web/web/in_app_web_view_web_element.dart 53:22 <fn> dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async packages/flutter_inappwebview_web/web/in_app_web_view_web_element.dart 51:42 <fn> packages/flutter/src/services/platform_channel.dart 571:55 _handleAsMethodCall dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async packages/flutter/src/services/platform_channel.dart 568:40 [_handleAsMethodCall] packages/flutter/src/services/platform_channel.dart 564:34 <fn> packages/flutter_web_plugins/src/plugin_registry.dart 125:33 handleFrameworkMessage dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async packages/flutter_web_plugins/src/plugin_registry.dart 116:38 handleFrameworkMessage lib/_engine/engine/platform_dispatcher.dart 721:7 [_sendPlatformMessage] lib/_engine/engine/platform_dispatcher.dart 414:5 sendPlatformMessage packages/flutter/src/services/binding.dart 558:27 send packages/flutter/src/services/platform_channel.dart 327:31 _invokeMethod dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async packages/flutter/src/services/platform_channel.dart 322:30 [_invokeMethod] packages/flutter/src/services/platform_channel.dart 507:12 invokeMethod packages/flutter_inappwebview_web/src/in_app_webview/in_app_webview_controller.dart 237:34 getUrl dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async packages/flutter_inappwebview_web/src/in_app_webview/in_app_webview_controller.dart 235:25 getUrl packages/flutter_inappwebview/src/in_app_webview/in_app_webview_controller.dart 48:40 getUrl packages/ynmo/view/internal_web_view.dart 98:33 [_getCurrentUrl] packages/ynmo/view/internal_web_view.dart 90:78 <fn> dart-sdk/lib/async/stream.dart 805:29 <fn> dart-sdk/lib/async/zone.dart 1594:9 runUnaryGuarded dart-sdk/lib/async/stream_impl.dart 365:5 [_sendData] dart-sdk/lib/async/stream_impl.dart 297:7 [_add] dart-sdk/lib/async/stream_controller.dart 784:5 [_sendData] dart-sdk/lib/async/stream_controller.dart 658:7 [_add] dart-sdk/lib/async/stream_controller.dart 606:5 add dart-sdk/lib/async/stream.dart 512:21 sendEvent dart-sdk/lib/async/stream.dart 531:13 <fn> dart-sdk/lib/_internal/js_dev_runtime/private/isolate_helper.dart 48:11 internalCallback

github-actions[bot] commented 5 months ago

👋 @hossameldinmi

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!

Joao-Pimenta commented 3 months ago

This is still an issue. Any news on this?

hossameldinmi commented 1 month ago

Any updates?