From 359e306c0058824701f43cb17e00b6b2ce850644 Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Thu, 23 Sep 2021 17:06:20 +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/webview_flutter_android/CHANGELOG.md | 4 ++++ .../webview_flutter_android/example/lib/main.dart | 8 ++++---- .../webview_flutter/webview_flutter_android/pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md index d6a10e9b918a..917a3c73acb1 100644 --- a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md +++ b/packages/webview_flutter/webview_flutter_android/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 Android implementation from `webview_flutter`. diff --git a/packages/webview_flutter/webview_flutter_android/example/lib/main.dart b/packages/webview_flutter/webview_flutter_android/example/lib/main.dart index 6176ce255eb9..65f49716aaac 100644 --- a/packages/webview_flutter/webview_flutter_android/example/lib/main.dart +++ b/packages/webview_flutter/webview_flutter_android/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_android/pubspec.yaml b/packages/webview_flutter/webview_flutter_android/pubspec.yaml index f7db4c6fb63a..4a3d4cb1d942 100644 --- a/packages/webview_flutter/webview_flutter_android/pubspec.yaml +++ b/packages/webview_flutter/webview_flutter_android/pubspec.yaml @@ -2,7 +2,7 @@ name: webview_flutter_android description: A Flutter plugin that provides a WebView widget on Android. repository: https://github.com/flutter/plugins/tree/master/packages/webview_flutter/webview_flutter_android 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"