Skip to content

Conversation

Hamed233
Copy link

@Hamed233 Hamed233 commented May 1, 2025

Issue

When using InAppWebViewKeepAlive, if the URL is changed from the initial URL and the WebView is removed and re-added to the widget tree, it loads the initial URL instead of the last URL that was navigated to.

Steps to reproduce:

  1. Load https://jumble.social/ and set keepAlive = InAppWebViewKeepAlive()
  2. Navigate to a different URL, like https://jumble.social/notes/bbb
  3. Close the WebView
  4. Reopen the WebView with the same InAppWebViewKeepAlive object
  5. The WebView loads https://jumble.social/ instead of https://jumble.social/notes/bbb

Fix

This PR adds URL tracking to the keepAlive functionality:

  1. Added a currentUrl property to the InAppWebViewControllerKeepAliveProps class
  2. Updated the onLoadStop event handlers in Android and iOS implementations to save the current URL to the keepAlive properties
  3. Modified the controller initialization code to restore the last URL when reusing a keepAlive object

Fixes #2613

@probot-autolabeler probot-autolabeler bot added android iOS linux Linux platform macOS macOS platform platform_interface Platform Interface plugin flutter_inappwebview plugin web windows Windows platform labels May 1, 2025
@begovsky
Copy link

begovsky commented May 4, 2025

@Hamed233 Please check my comment here:
#2613 (comment)

@aceHubert
Copy link

image
Missing a import

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

android iOS linux Linux platform macOS macOS platform platform_interface Platform Interface plugin flutter_inappwebview plugin web windows Windows platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keepalive not working when url changed

3 participants