Skip to content

Commit 78de28c

Browse files
[webview_flutter_platform_interface] Updates platform interface to new interface (#6846)
* Set new interface in main * update pubspec changelog and readme * exclude from all plugins app test * delete all of platform interface * add all back to platform interface
1 parent 3a093e4 commit 78de28c

File tree

58 files changed

+606
-1539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+606
-1539
lines changed

packages/webview_flutter/webview_flutter_platform_interface/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 2.0.0
2+
3+
* **Breaking Change**: Releases new interface. See [documentation](https://pub.dev/documentation/webview_flutter_platform_interface/2.0.0/) and [design doc](https://flutter.dev/go/webview_flutter_4_interface)
4+
for more details.
5+
* **Breaking Change**: Removes MethodChannel implementation of interface. All platform
6+
implementations will now need to create their own by implementing `WebViewPlatform`.
7+
18
## 1.9.5
29

310
* Updates code for `no_leading_underscores_for_local_identifiers` lint.

packages/webview_flutter/webview_flutter_platform_interface/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ same interface.
99
# Usage
1010

1111
To implement a new platform-specific implementation of `webview_flutter`, extend
12-
[`WebviewPlatform`](lib/src/platform_interface/webview_platform.dart) with an implementation that performs the
12+
[`WebviewPlatform`](lib/src/webview_platform.dart) with an implementation that performs the
1313
platform-specific behavior, and when you register your plugin, set the default
1414
`WebviewPlatform` by calling
15-
`WebviewPlatform.setInstance(MyPlatformWebview())`.
15+
`WebviewPlatform.instance = MyPlatformWebview()`.
1616

1717
# Note on breaking changes
1818

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
/// A message that was sent by JavaScript code running in a [WebView].
6+
class JavascriptMessage {
7+
/// Constructs a JavaScript message object.
8+
///
9+
/// The `message` parameter must not be null.
10+
const JavascriptMessage(this.message) : assert(message != null);
11+
12+
/// The contents of the message that was sent by the JavaScript code.
13+
final String message;
14+
}

packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/types/javascript_mode.dart renamed to packages/webview_flutter/webview_flutter_platform_interface/lib/src/legacy/types/javascript_mode.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// found in the LICENSE file.
44

55
/// Describes the state of JavaScript support in a given web view.
6-
enum JavaScriptMode {
6+
enum JavascriptMode {
77
/// JavaScript execution is disabled.
88
disabled,
99

packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/types/types.dart renamed to packages/webview_flutter/webview_flutter_platform_interface/lib/src/legacy/types/types.dart

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
export 'auto_media_playback_policy.dart';
6+
export 'creation_params.dart';
7+
export 'javascript_channel.dart';
58
export 'javascript_message.dart';
69
export 'javascript_mode.dart';
7-
export 'load_request_params.dart';
8-
export 'platform_navigation_delegate_creation_params.dart';
9-
export 'platform_webview_controller_creation_params.dart';
10-
export 'platform_webview_cookie_manager_creation_params.dart';
11-
export 'platform_webview_widget_creation_params.dart';
1210
export 'web_resource_error.dart';
11+
export 'web_resource_error_type.dart';
12+
export 'web_settings.dart';
1313
export 'webview_cookie.dart';
14+
export 'webview_request.dart';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'web_resource_error_type.dart';
6+
7+
/// Error returned in `WebView.onWebResourceError` when a web resource loading error has occurred.
8+
class WebResourceError {
9+
/// Creates a new [WebResourceError]
10+
///
11+
/// A user should not need to instantiate this class, but will receive one in
12+
/// [WebResourceErrorCallback].
13+
WebResourceError({
14+
required this.errorCode,
15+
required this.description,
16+
this.domain,
17+
this.errorType,
18+
this.failingUrl,
19+
}) : assert(errorCode != null),
20+
assert(description != null);
21+
22+
/// Raw code of the error from the respective platform.
23+
///
24+
/// On Android, the error code will be a constant from a
25+
/// [WebViewClient](https://developer.android.com/reference/android/webkit/WebViewClient#summary) and
26+
/// will have a corresponding [errorType].
27+
///
28+
/// On iOS, the error code will be a constant from `NSError.code` in
29+
/// Objective-C. See
30+
/// https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/ErrorObjectsDomains/ErrorObjectsDomains.html
31+
/// for more information on error handling on iOS. Some possible error codes
32+
/// can be found at https://developer.apple.com/documentation/webkit/wkerrorcode?language=objc.
33+
final int errorCode;
34+
35+
/// The domain of where to find the error code.
36+
///
37+
/// This field is only available on iOS and represents a "domain" from where
38+
/// the [errorCode] is from. This value is taken directly from an `NSError`
39+
/// in Objective-C. See
40+
/// https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/ErrorObjectsDomains/ErrorObjectsDomains.html
41+
/// for more information on error handling on iOS.
42+
final String? domain;
43+
44+
/// Description of the error that can be used to communicate the problem to the user.
45+
final String description;
46+
47+
/// The type this error can be categorized as.
48+
///
49+
/// This will never be `null` on Android, but can be `null` on iOS.
50+
final WebResourceErrorType? errorType;
51+
52+
/// Gets the URL for which the resource request was made.
53+
///
54+
/// This value is not provided on iOS. Alternatively, you can keep track of
55+
/// the last values provided to [WebViewPlatformController.loadUrl].
56+
final String? failingUrl;
57+
}

packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/types/webview_cookie.dart renamed to packages/webview_flutter/webview_flutter_platform_interface/lib/src/legacy/types/webview_cookie.dart

+20-12
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'package:flutter/foundation.dart';
6-
7-
/// A cookie that can be set globally for all web views using [WebViewCookieManagerPlatform].
8-
@immutable
5+
/// A cookie that can be set globally for all web views
6+
/// using [WebViewCookieManagerPlatform].
97
class WebViewCookie {
10-
/// Creates a new [WebViewCookieDelegate]
11-
const WebViewCookie({
12-
required this.name,
13-
required this.value,
14-
required this.domain,
15-
this.path = '/',
16-
});
8+
/// Constructs a new [WebViewCookie].
9+
const WebViewCookie(
10+
{required this.name,
11+
required this.value,
12+
required this.domain,
13+
this.path = '/'});
1714

1815
/// The cookie-name of the cookie.
1916
///
@@ -33,9 +30,20 @@ class WebViewCookie {
3330
/// https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-02#section-4.1.1
3431
final String domain;
3532

36-
/// The path-value of the cookie, set to `/` by default.
33+
/// The path-value of the cookie.
34+
/// Is set to `/` in the constructor by default.
3735
///
3836
/// Its value should match "path-value" in RFC6265bis:
3937
/// https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-02#section-4.1.1
4038
final String path;
39+
40+
/// Serializes the [WebViewCookie] to a Map<String, String>.
41+
Map<String, String> toJson() {
42+
return <String, String>{
43+
'name': name,
44+
'value': value,
45+
'domain': domain,
46+
'path': path
47+
};
48+
}
4149
}

0 commit comments

Comments
 (0)