From be5c20211af9e34a882581293c8693a8a2ef79f9 Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Thu, 23 Sep 2021 17:12:51 +0200 Subject: [PATCH] Load navigation controls immediately. Make sure the navigation controls in the example App are loaded immediately but only enable when the WebViewController is available. This is the same behavior as in the example App from the main webview_flutter package. --- .../webview_flutter_wkwebview/CHANGELOG.md | 4 ++++ .../webview_flutter_wkwebview/example/lib/main.dart | 8 ++++---- .../webview_flutter_wkwebview/pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md b/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md index 1a85bc8a53e5..242d79b4bd82 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md +++ b/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.14 + +* Update example App so navigation menu loads immediatly but only becomes available when `WebViewController` is available (same behavior as example App in webview_flutter package). + ## 2.0.13 * Extract WKWebView implementation from `webview_flutter`. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/lib/main.dart b/packages/webview_flutter/webview_flutter_wkwebview/example/lib/main.dart index a953e062ded5..15b4cfc7c549 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/lib/main.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/lib/main.dart @@ -289,7 +289,7 @@ class _NavigationControls extends StatelessWidget { final bool webViewReady = snapshot.connectionState == ConnectionState.done; final WebViewController? controller = snapshot.data; - if (controller == null) return Container(); + return Row( children: [ IconButton( @@ -297,7 +297,7 @@ class _NavigationControls extends StatelessWidget { onPressed: !webViewReady ? null : () async { - if (await controller.canGoBack()) { + if (await controller!.canGoBack()) { await controller.goBack(); } else { // ignore: deprecated_member_use @@ -313,7 +313,7 @@ class _NavigationControls extends StatelessWidget { onPressed: !webViewReady ? null : () async { - if (await controller.canGoForward()) { + if (await controller!.canGoForward()) { await controller.goForward(); } else { // ignore: deprecated_member_use @@ -330,7 +330,7 @@ class _NavigationControls extends StatelessWidget { onPressed: !webViewReady ? null : () { - controller.reload(); + controller!.reload(); }, ), ], diff --git a/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml b/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml index c6f6d6f94f07..a7305cea7a94 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml +++ b/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml @@ -2,7 +2,7 @@ name: webview_flutter_wkwebview description: A Flutter plugin that provides a WebView widget based on Apple's WKWebView control. repository: https://github.com/flutter/plugins/tree/master/packages/webview_flutter/webview_flutter_wkwebview issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22 -version: 2.0.13 +version: 2.0.14 environment: sdk: ">=2.14.0 <3.0.0"