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 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7f876d1
copy code from v4_webview
bparrishMines Dec 15, 2022
56fceb9
version bump and readme update
bparrishMines Dec 15, 2022
2a4b7d3
work towards better readme
bparrishMines Dec 15, 2022
e90e7df
Merge branch 'main' of github.com:flutter/plugins into webview_flutte…
bparrishMines Dec 15, 2022
b2480f8
improvements
bparrishMines Dec 15, 2022
0d4e703
more readme progress
bparrishMines Dec 16, 2022
9968f38
Merge branch 'main' of github.com:flutter/plugins into webview_flutte…
bparrishMines Dec 16, 2022
301fafa
improvements
bparrishMines Dec 16, 2022
e56c091
fix main and update more readme
bparrishMines Dec 16, 2022
65d28ed
excerpt changes and more 3.0 diffs
bparrishMines Dec 16, 2022
c41fa5b
cookie manager update
bparrishMines Dec 16, 2022
f5e7243
remove packages from exclude list
bparrishMines Dec 16, 2022
720082e
lint
bparrishMines Dec 16, 2022
de00284
better range
bparrishMines Dec 16, 2022
fc2d6cb
isForMainFrame
bparrishMines Dec 16, 2022
f1c7a65
load page after waiting for widget
bparrishMines Dec 16, 2022
b206a23
fix integration tests
bparrishMines Dec 16, 2022
998d8ae
Merge branch 'main' of github.com:flutter/plugins into webview_flutte…
bparrishMines Dec 16, 2022
a496fef
improve readme a bit
bparrishMines Dec 16, 2022
feb0b2e
collapse changelong. update platform-specific wording. include in exc…
bparrishMines Dec 16, 2022
fcf987d
use platform implementation packages
bparrishMines Dec 16, 2022
4ff354b
include missing exports
bparrishMines Dec 16, 2022
72f1db8
PR comments
bparrishMines Dec 16, 2022
45d1a34
correct spelling
bparrishMines Dec 16, 2022
cc30a02
Merge branch 'main' of github.com:flutter/plugins into webview_flutte…
bparrishMines Dec 16, 2022
cc24cbb
interface dev dependency
bparrishMines Dec 16, 2022
52069b3
move other usage above migration
bparrishMines Dec 17, 2022
dbc20fa
remove interface classes
bparrishMines Dec 17, 2022
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
Prev Previous commit
Next Next commit
fix main and update more readme
  • Loading branch information
bparrishMines committed Dec 16, 2022
commit e56c09141b1da30d7ed3062bd1a1d38ed60f7ea8
6 changes: 4 additions & 2 deletions packages/webview_flutter/webview_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
## 4.0.0

* **BREAKING CHANGE** See README for details on migrating from version 3.0.
* **BREAKING CHANGE** Updates implementation to use the `2.0.0` release of
`webview_flutter_platform_interface`. See `Usage` section in the README for updated usage. See
`Migrating from 3.0 to 4.0` section in the README for details on migrating to this version.
* Updates code for `no_leading_underscores_for_local_identifiers` lint.
* Updates minimum Flutter version to 2.10.
* Updates minimum Flutter version to 3.0.0.
* Fixes avoid_redundant_argument_values lint warnings and minor typos.
* Ignores unnecessary import warnings in preparation for [upcoming Flutter changes](https://github.com/flutter/flutter/pull/104231).
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's collapse these two and the underscores one above to a catch-all "Updates code for new analysis options." so there's less minor stuff listed in with the big change.

* Updates references to the obsolete master branch.
Expand Down
27 changes: 21 additions & 6 deletions packages/webview_flutter/webview_flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,18 @@ import 'package:webview_flutter/android.dart';
import 'package:webview_flutter/wkwebview.dart';
Copy link
Contributor

Choose a reason for hiding this comment

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

We should remove these files entirely, and show importing from the packages instead, because if we re-export platform-specific packages, then any breaking change to those packages' platform-specific APIs will require a breaking change to the app-facing package as well, which we don't want.

Using the implementation packages directly for platform features is the pattern we're using in other plugins (local_auth, IAP, etc.)

Copy link
Contributor Author

@bparrishMines bparrishMines Dec 16, 2022

Choose a reason for hiding this comment

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

I agree with this approach. I like the app-facing package to remain mostly unaware of its implementations.

But to do this, I also had to add LoadRequestParams and JavaScriptChannelParams to the webview_flutter.dart export. I'm considering some other options,

  1. We could export LoadRequestParams and JavaScriptChannelParams in the platform implementations instead.
  2. Create a import 'package:webview_flutter/platform_interface.dart' export file.
  3. Require apps to import the platform interface when importing the platform implementations.
  4. Leave it as is.

My preference is to export these classes in the platform implementation classes. This would allow us import the minimum needed in the app-facing package and not require any additional work for a user to use the platform implementation classes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, 1 seems like the best option. It also seems like the most consistent with the general policy that an interface should export all the types used in its public API (comparable to the lint about not using private classes in public APIs).

```

Then additional features can be accessed through the platform implementations provided by the
imports above:
Now, additional features can be accessed through the platform implementations. Classes
`WebViewController`, `WebViewWidget`, `NavigationDelegate`, and `WebViewCookieManager` pass their
functionality to a class provided by the current platform. Below are a couple of ways to access
additional functionality provided by the platform and is followed by an example.

1. Pass a creation params class provided by a platform implementation to a `fromPlatformCreationParams`
constructor (e.g. `WebViewController.fromPlatformCreationParams`,
`WebViewWidget.fromPlatformCreationParams`, etc...).
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: just "etc." rather than "etc..."

2. Calling methods on a platform implementation of a class by using the `platform` field (e.g.
`WebViewController.platform`, `WebViewWidget.platform`, etc...).

Below is an example of setting additional iOS and Android parameters to the WebViewController.

<?code-excerpt "main.dart (platform_features)"?>
```dart
Expand Down Expand Up @@ -190,10 +200,15 @@ Below is a non-exhaustive list of changes to the API:
* `WebView.zoomEnabled` -> `WebViewController.enableZoom`
* `WebView.userAgent` -> `WebViewController.setUserAgent`
* `WebView.backgroundColor` -> `WebViewController.setBackgroundColor`
* The following features have been moved to an Android implementation class. See
`aoijfea` section to use platform specific features.
* The following features have been moved to an Android implementation class. See
`aoijfea` section to use platform specific features.
* The following features have been moved to an Android implementation class. See section
`Platform Specific Features` for details on accessing Android platform specific features.
* `WebView.debuggingEnabled` -> `AndroidWebViewController.enableDebugging`
* `WebView.initialMediaPlaybackPolicy` -> `AndroidWebViewController.setMediaPlaybackRequiresUserGesture`
* The following features have been moved to an iOS implementation class. See section
`Platform Specific Features` for details on accessing iOS platform specific features.
* `WebView.gestureNavigationEnabled` -> `WebKitWebViewController.setAllowsBackForwardNavigationGestures`
* `WebView.initialMediaPlaybackPolicy` -> `WebKitWebViewControllerCreationParams.mediaTypesRequiringUserAction`
* `WebView.allowsInlineMediaPlayback` -> `WebKitWebViewControllerCreationParams.allowsInlineMediaPlayback`

## Enable Material Components for Android
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this and the next section still be ### headings under ## Usage?


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ Page resource error:
..loadRequest(Uri.parse('https://flutter.dev'));

// #docregion platform_features
if (controller is AndroidWebViewController) {
if (controller.platform is AndroidWebViewController) {
AndroidWebViewController.enableDebugging(true);
(controller as AndroidWebViewController)
(controller.platform as AndroidWebViewController)
.setMediaPlaybackRequiresUserGesture(false);
}
// #enddocregion platform_features
Expand Down
2 changes: 1 addition & 1 deletion packages/webview_flutter/webview_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies:
sdk: flutter
webview_flutter_android: 3.0.0
webview_flutter_platform_interface: 2.0.0
#webview_flutter_wkwebview: 3.0.0
webview_flutter_wkwebview: 3.0.0

dev_dependencies:
build_runner: ^2.1.5
Expand Down