Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
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
5 changes: 5 additions & 0 deletions packages/webview_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.3.17

* Fix pedantic lint errors. Added missing documentation and awaited some futures
in tests and the example app.

## 0.3.16

* Add support for async NavigationDelegates. Synchronous NavigationDelegates
Expand Down
11 changes: 0 additions & 11 deletions packages/webview_flutter/analysis_options.yaml

This file was deleted.

10 changes: 6 additions & 4 deletions packages/webview_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// ignore_for_file: public_member_api_docs

import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -194,7 +196,7 @@ class SampleMenu extends StatelessWidget {
WebViewController controller, BuildContext context) async {
// Send a message with the user agent string to the Toaster JavaScript channel we registered
// with the WebView.
controller.evaluateJavascript(
await controller.evaluateJavascript(
'Toaster.postMessage("User Agent: " + navigator.userAgent);');
}

Expand Down Expand Up @@ -250,7 +252,7 @@ class SampleMenu extends StatelessWidget {
WebViewController controller, BuildContext context) async {
final String contentBase64 =
base64Encode(const Utf8Encoder().convert(kNavigationExamplePage));
controller.loadUrl('data:text/html;base64,$contentBase64');
await controller.loadUrl('data:text/html;base64,$contentBase64');
}

Widget _getCookieList(String cookies) {
Expand Down Expand Up @@ -291,7 +293,7 @@ class NavigationControls extends StatelessWidget {
? null
: () async {
if (await controller.canGoBack()) {
controller.goBack();
await controller.goBack();
} else {
Scaffold.of(context).showSnackBar(
const SnackBar(content: Text("No back history item")),
Expand All @@ -306,7 +308,7 @@ class NavigationControls extends StatelessWidget {
? null
: () async {
if (await controller.canGoForward()) {
controller.goForward();
await controller.goForward();
} else {
Scaffold.of(context).showSnackBar(
const SnackBar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
final String result =
await driver.requestData(null, timeout: const Duration(minutes: 1));
driver.close();
await driver.close();
exit(result == 'pass' ? 0 : 1);
}
8 changes: 8 additions & 0 deletions packages/webview_flutter/lib/platform_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ class WebSetting<T> {
///
/// The `userAgent` parameter must not be null.
class WebSettings {
/// Construct an instance with initial settings. Future setting changes can be
/// sent with [WebviewPlatform#updateSettings].
///
/// The `userAgent` parameter must not be null.
WebSettings({
this.javascriptMode,
this.hasNavigationDelegate,
Expand Down Expand Up @@ -258,6 +262,10 @@ class WebSettings {
///
/// The `autoMediaPlaybackPolicy` parameter must not be null.
class CreationParams {
/// Constructs an instance to use when creating a new
/// [WebViewPlatformController].
///
/// The `autoMediaPlaybackPolicy` parameter must not be null.
CreationParams({
this.initialUrl,
this.webSettings,
Expand Down
2 changes: 2 additions & 0 deletions packages/webview_flutter/lib/src/webview_method_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import '../platform_interface.dart';

/// A [WebViewPlatformController] that uses a method channel to control the webview.
class MethodChannelWebViewPlatform implements WebViewPlatformController {
/// Constructs an instance that will listen for webviews broadcasting to the
/// given [id], using the given [WebViewPlatformCallbacksHandler].
MethodChannelWebViewPlatform(int id, this._platformCallbacksHandler)
: assert(_platformCallbacksHandler != null),
_channel = MethodChannel('plugins.flutter.io/webview_$id') {
Expand Down
8 changes: 6 additions & 2 deletions packages/webview_flutter/lib/webview_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ import 'platform_interface.dart';
import 'src/webview_android.dart';
import 'src/webview_cupertino.dart';

/// Optional callback invoked when a web view is first created. [controller] is
/// the [WebViewController] for the created web view.
typedef void WebViewCreatedCallback(WebViewController controller);

/// Describes the state of JavaScript support in a given web view.
enum JavascriptMode {
/// JavaScript execution is disabled.
disabled,
Expand Down Expand Up @@ -589,10 +592,11 @@ class WebViewController {
final Set<String> channelsToRemove =
currentChannels.difference(newChannelNames);
if (channelsToRemove.isNotEmpty) {
_webViewPlatformController.removeJavascriptChannels(channelsToRemove);
await _webViewPlatformController
.removeJavascriptChannels(channelsToRemove);
}
if (channelsToAdd.isNotEmpty) {
_webViewPlatformController.addJavascriptChannels(channelsToAdd);
await _webViewPlatformController.addJavascriptChannels(channelsToAdd);
}
_platformCallbacksHandler._updateJavascriptChannelsFromSet(newChannels);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/webview_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: webview_flutter
description: A Flutter plugin that provides a WebView widget on Android and iOS.
version: 0.3.16
version: 0.3.17
author: Flutter Team <[email protected]>
homepage: https://github.com/flutter/plugins/tree/master/packages/webview_flutter

Expand Down
22 changes: 11 additions & 11 deletions packages/webview_flutter/test/webview_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void main() {

expect(controller, isNotNull);

controller.loadUrl('https://flutter.io');
await controller.loadUrl('https://flutter.io');

expect(await controller.currentUrl(), 'https://flutter.io');
});
Expand Down Expand Up @@ -272,11 +272,11 @@ void main() {

expect(await controller.currentUrl(), 'https://youtube.com');

controller.loadUrl('https://flutter.io');
await controller.loadUrl('https://flutter.io');

expect(await controller.currentUrl(), 'https://flutter.io');

controller.goBack();
await controller.goBack();

expect(await controller.currentUrl(), 'https://youtube.com');
});
Expand All @@ -296,15 +296,15 @@ void main() {

expect(await controller.currentUrl(), 'https://youtube.com');

controller.loadUrl('https://flutter.io');
await controller.loadUrl('https://flutter.io');

expect(await controller.currentUrl(), 'https://flutter.io');

controller.goBack();
await controller.goBack();

expect(await controller.currentUrl(), 'https://youtube.com');

controller.goForward();
await controller.goForward();

expect(await controller.currentUrl(), 'https://flutter.io');
});
Expand All @@ -324,13 +324,13 @@ void main() {
// Test a WebView without an explicitly set first URL.
expect(await controller.currentUrl(), isNull);

controller.loadUrl('https://youtube.com');
await controller.loadUrl('https://youtube.com');
expect(await controller.currentUrl(), 'https://youtube.com');

controller.loadUrl('https://flutter.io');
await controller.loadUrl('https://flutter.io');
expect(await controller.currentUrl(), 'https://flutter.io');

controller.goBack();
await controller.goBack();
expect(await controller.currentUrl(), 'https://youtube.com');
});

Expand All @@ -351,12 +351,12 @@ void main() {
expect(platformWebView.currentUrl, 'https://flutter.io');
expect(platformWebView.amountOfReloadsOnCurrentUrl, 0);

controller.reload();
await controller.reload();

expect(platformWebView.currentUrl, 'https://flutter.io');
expect(platformWebView.amountOfReloadsOnCurrentUrl, 1);

controller.loadUrl('https://youtube.com');
await controller.loadUrl('https://youtube.com');

expect(platformWebView.amountOfReloadsOnCurrentUrl, 0);
});
Expand Down