Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Prev Previous commit
Next Next commit
review comments follow-up
  • Loading branch information
amirh committed Mar 7, 2019
commit 8ac15be612a09c774c60efc2ca1130e67007c5a6
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.webviewflutter;

import android.annotation.TargetApi;
Expand Down
3 changes: 2 additions & 1 deletion packages/webview_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ void main() => runApp(MaterialApp(home: WebViewExample()));

const String kNavigationExamplePage = '''
<!DOCTYPE html><html>
<head><title>Navigation Delegate Example</title></head>thanks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray "thanks"

<body>
<p>
The navigation delegate is set to block navigation to the youtube website.
Expand Down Expand Up @@ -53,7 +54,7 @@ class WebViewExample extends StatelessWidget {
_toasterJavascriptChannel(context),
].toSet(),
navigationDelegate: (NavigationRequest request) {
if (request.url == 'https://www.youtube.com/') {
if (request.url.startsWith('https://www.youtube.com/')) {
print('blocking navigation to $request}');
return NavigationDecision.prevent;
}
Expand Down
8 changes: 4 additions & 4 deletions packages/webview_flutter/lib/webview_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ typedef void JavascriptMessageHandler(JavascriptMessage message);

/// Information about a navigation action that is about to be executed.
class NavigationRequest {
NavigationRequest({this.url, this.isMainFrame});
NavigationRequest._({this.url, this.isMainFrame});

/// The URL a navigation is requested to.
/// The URL that will be loaded if the navigation is executed.
final String url;

/// Whether the navigation request originated from the main HTML frame.
final bool isMainFrame;

@override
String toString() {
return 'NavigationRequest(url: $url, isMainFrame: $isMainFrame)';
return '$runtimeType(url: $url, isMainFrame: $isMainFrame)';
}
}

Expand Down Expand Up @@ -376,7 +376,7 @@ class WebViewController {
.onMessageReceived(JavascriptMessage(message));
break;
case 'navigationRequest':
final NavigationRequest request = NavigationRequest(
final NavigationRequest request = NavigationRequest._(
url: call.arguments['url'],
isMainFrame: call.arguments['isMainFrame'],
);
Expand Down