Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.10.7

* Replaces use of deprecated Color.value.

## 4.10.6

* Updates to Pigeon 26.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ class AndroidWebViewController extends PlatformWebViewController {

@override
Future<void> setBackgroundColor(Color color) =>
_webView.setBackgroundColor(color.value);
_webView.setBackgroundColor(color.toARGB32());

@override
Future<void> setJavaScriptMode(JavaScriptMode javaScriptMode) => _webView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ class WebViewAndroidPlatformController extends WebViewPlatformController {

final Color? backgroundColor = creationParams.backgroundColor;
if (backgroundColor != null) {
webView.setBackgroundColor(backgroundColor.value);
webView.setBackgroundColor(backgroundColor.toARGB32());
}

addJavascriptChannels(creationParams.javascriptChannelNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class SurfaceAndroidWebView extends AndroidWebView {
// AndroidViewSurface. This switches the WebView to Hybrid
// Composition when the background color is not 100% opaque.
hybridComposition:
backgroundColor != null && backgroundColor.opacity < 1.0,
backgroundColor != null && backgroundColor.a < 1.0,

Choose a reason for hiding this comment

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

critical

The condition backgroundColor.a < 1.0 for enabling hybrid composition seems incorrect. The Color.a property is an integer ranging from 0 to 255, representing the alpha channel. This condition will only be true for a fully transparent color (a == 0), but not for other semi-transparent colors.

The original condition backgroundColor.opacity < 1.0 was correct. If you want to use the integer alpha value, the condition should be backgroundColor.alpha < 255.

Suggested change
backgroundColor != null && backgroundColor.a < 1.0,
backgroundColor != null && backgroundColor.alpha < 255,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The Color.a property is an integer ranging from 0 to 255

This is a lie, it's a double from 0-1.

id: params.id,
viewType: 'plugins.flutter.io/webview',
// WebView content is not affected by the Android view's layout direction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: webview_flutter_android
description: A Flutter plugin that provides a WebView widget on Android.
repository: https://github.com/flutter/packages/tree/main/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: 4.10.6
version: 4.10.7

environment:
sdk: ^3.9.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ void main() {

await controller.setBackgroundColor(Colors.blue);

verify(mockWebView.setBackgroundColor(Colors.blue.value)).called(1);
verify(mockWebView.setBackgroundColor(Colors.blue.toARGB32())).called(1);
});

test('setJavaScriptMode', () async {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.23.4

* Replaces use of deprecated Color.value.

## 3.23.3

* Updates to Pigeon 26.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,11 @@ class WebKitWebViewPlatformController extends WebViewPlatformController {

if (params.backgroundColor != null) {
unawaited(webView.setOpaque(false));
unawaited(webView.setBackgroundColor(Colors.transparent.value));
unawaited(webView.setBackgroundColor(Colors.transparent.toARGB32()));
unawaited(
webView.scrollView.setBackgroundColor(params.backgroundColor?.value),
webView.scrollView.setBackgroundColor(
params.backgroundColor?.toARGB32(),
),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,9 @@ class WebKitWebViewController extends PlatformWebViewController {
Future<void> setBackgroundColor(Color color) {
return Future.wait(<Future<void>>[
_webView.setOpaque(false),
_webView.setBackgroundColor(Colors.transparent.value),
_webView.setBackgroundColor(Colors.transparent.toARGB32()),
// This method must be called last.
_webView.scrollView.setBackgroundColor(color.value),
_webView.scrollView.setBackgroundColor(color.toARGB32()),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,9 @@ abstract class WKWebsiteDataStore extends NSObject {
)
abstract class UIView extends NSObject {
/// The view’s background color.
// TODO(bparrishMines): Using an int here is lossy, and should be replaced
// with a full color representation. See
// https://github.com/flutter/flutter/issues/178870.
void setBackgroundColor(int? value);

/// A Boolean value that determines whether the view is opaque.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: webview_flutter_wkwebview
description: A Flutter plugin that provides a WebView widget based on Apple's WKWebView control.
repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_wkwebview
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
version: 3.23.3
version: 3.23.4

environment:
sdk: ^3.9.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ void main() {
);

verify(mocks.webView.setOpaque(false));
verify(mocks.webView.setBackgroundColor(Colors.transparent.value));
verify(mocks.scrollView.setBackgroundColor(Colors.red.value));
verify(mocks.webView.setBackgroundColor(Colors.transparent.toARGB32()));
verify(mocks.scrollView.setBackgroundColor(Colors.red.toARGB32()));

debugDefaultTargetPlatformOverride = null;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,8 @@ void main() {
// UIScrollView.setBackgroundColor must be called last.
verifyInOrder(<Object>[
mockWebView.setOpaque(false),
mockWebView.setBackgroundColor(Colors.transparent.value),
mockScrollView.setBackgroundColor(Colors.red.value),
mockWebView.setBackgroundColor(Colors.transparent.toARGB32()),
mockScrollView.setBackgroundColor(Colors.red.toARGB32()),
]);

debugDefaultTargetPlatformOverride = null;
Expand Down