Skip to content

Commit

Permalink
Fix in-app browser URL issue (#1106)
Browse files Browse the repository at this point in the history
  • Loading branch information
micahmo authored Feb 5, 2024
1 parent 799b731 commit 5148b8e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/shared/webview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class WebView extends StatefulWidget {
class _WebViewState extends State<WebView> {
late final WebViewController _controller;

// Keeps track of the URL that we are currently viewing, not necessarily the original
String? currentUrl;

@override
void initState() {
super.initState();
Expand All @@ -40,7 +43,7 @@ class _WebViewState extends State<WebView> {
..setNavigationDelegate(NavigationDelegate())
..loadRequest(Uri.parse(widget.url))
..setNavigationDelegate(NavigationDelegate(
onUrlChange: (_) => setState(() {}),
onUrlChange: (urlChange) => setState(() => currentUrl = urlChange.url),
));

if (controller.platform is AndroidWebViewController) {
Expand All @@ -64,7 +67,7 @@ class _WebViewState extends State<WebView> {
actions: <Widget>[
NavigationControls(
webViewController: _controller,
url: widget.url,
url: currentUrl ?? widget.url,
)
],
),
Expand Down

0 comments on commit 5148b8e

Please sign in to comment.