Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController
props.webMessageChannels as Set<AndroidWebMessageChannel>;
_webMessageListeners =
props.webMessageListeners as Set<AndroidWebMessageListener>;
// restore the last URL if available
if (props.currentUrl != null) {
loadUrl(urlRequest: URLRequest(url: props.currentUrl));
}
}
}
}
Expand Down Expand Up @@ -214,6 +218,18 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController
_inAppBrowserEventHandler != null) {
String? url = call.arguments["url"];
WebUri? uri = url != null ? WebUri(url) : null;

// Update the current URL in the keepAlive properties
final keepAlive = webviewParams is PlatformInAppWebViewWidgetCreationParams ?
(webviewParams as PlatformInAppWebViewWidgetCreationParams).keepAlive : null;
if (keepAlive != null && uri != null) {
InAppWebViewControllerKeepAliveProps? props = _keepAliveMap[keepAlive];
if (props != null) {
props.currentUrl = uri;
_keepAliveMap[keepAlive] = props;
}
}

if (webviewParams != null && webviewParams!.onLoadStop != null)
webviewParams!.onLoadStop!(_controllerFromPlatform, uri);
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
props.webMessageChannels as Set<IOSWebMessageChannel>;
_webMessageListeners =
props.webMessageListeners as Set<IOSWebMessageListener>;
// restore the last URL if available
if (props.currentUrl != null) {
loadUrl(urlRequest: URLRequest(url: props.currentUrl));
}
}
}
}
Expand Down Expand Up @@ -212,6 +216,18 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
_inAppBrowserEventHandler != null) {
String? url = call.arguments["url"];
WebUri? uri = url != null ? WebUri(url) : null;

// Update the current URL in the keepAlive properties
final keepAlive = webviewParams is PlatformInAppWebViewWidgetCreationParams ?
(webviewParams as PlatformInAppWebViewWidgetCreationParams).keepAlive : null;
if (keepAlive != null && uri != null) {
InAppWebViewControllerKeepAliveProps? props = _keepAliveMap[keepAlive];
if (props != null) {
props.currentUrl = uri;
_keepAliveMap[keepAlive] = props;
}
}

if (webviewParams != null && webviewParams!.onLoadStop != null)
webviewParams!.onLoadStop!(_controllerFromPlatform, uri);
else
Expand Down Expand Up @@ -1605,7 +1621,7 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
html =
await (await htmlRequest.close()).transform(Utf8Decoder()).join();
} catch (e) {
developer.log(e.toString(), name: this.runtimeType.toString());
developer.log(e.toString(), name: runtimeType.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class InAppWebViewControllerKeepAliveProps {
Set<PlatformWebMessageChannel> webMessageChannels = Set();
Set<PlatformWebMessageListener> webMessageListeners = Set();
Map<String, Function(dynamic data)> devToolsProtocolEventListenerMap;
WebUri? currentUrl;

InAppWebViewControllerKeepAliveProps(
{this.javaScriptHandlersMap = const {},
Expand All @@ -37,5 +38,6 @@ class InAppWebViewControllerKeepAliveProps {
this.injectedScriptsFromURL = const {},
this.webMessageChannels = const {},
this.webMessageListeners = const {},
this.devToolsProtocolEventListenerMap = const {}});
this.devToolsProtocolEventListenerMap = const {},
this.currentUrl});
}