Skip to content

Conversation

@stuartmorgan-g
Copy link
Collaborator

Replaces the deprecated Color.value with the equivalent Color.toARGB(). For iOS, where this is not the ideal long-term solution, adds a TODO for a better replacement.

Part of flutter/flutter#159739

Pre-Review Checklist

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Replaces the deprecated `Color.value` with the equivalent
`Color.toARGB()`. For iOS, where this is not the ideal long-term
solution, adds a TODO for a better replacement.

Part of flutter/flutter#159739
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly replaces the deprecated Color.value with Color.toARGB32() across the Android and WKWebView implementations. The changes in the production code and tests are appropriate. However, I found a critical issue in webview_surface_android.dart where the logic to detect semi-transparent colors for enabling hybrid composition is incorrect, which could lead to rendering issues.

// 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.

Copy link
Contributor

@bparrishMines bparrishMines left a comment

Choose a reason for hiding this comment

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

LGTM

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 20, 2025
@auto-submit auto-submit bot merged commit ad21d8d into flutter:main Nov 20, 2025
80 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 21, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Nov 21, 2025
flutter/packages@b1e2fb0...e67b6be

2025-11-21 [email protected] [file_selector] Implement
canCreateDirectories on macos and linux (flutter/packages#10443)
2025-11-21 [email protected] [various] Replace deprecated
Color.value in SVG packages (flutter/packages#10482)
2025-11-20 [email protected] [pigeon]
Fixes compilation error with unbounded type parameter for
InstanceManager (flutter/packages#10483)
2025-11-20 [email protected] [webview_flutter] Replace deprecated
Color.value (flutter/packages#10480)
2025-11-20 [email protected] [google_maps_flutter] Replace
deprecated color APIs in platform interface (flutter/packages#10477)
2025-11-20 [email protected] Roll Flutter (stable) from
b45fa18 to f5a8537 (12 revisions) (flutter/packages#10478)
2025-11-20 [email protected] Roll Flutter from
de4be4f to 9f383e0 (21 revisions) (flutter/packages#10481)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
okorohelijah pushed a commit to okorohelijah/flutter that referenced this pull request Nov 21, 2025
…r#178927)

flutter/packages@b1e2fb0...e67b6be

2025-11-21 [email protected] [file_selector] Implement
canCreateDirectories on macos and linux (flutter/packages#10443)
2025-11-21 [email protected] [various] Replace deprecated
Color.value in SVG packages (flutter/packages#10482)
2025-11-20 [email protected] [pigeon]
Fixes compilation error with unbounded type parameter for
InstanceManager (flutter/packages#10483)
2025-11-20 [email protected] [webview_flutter] Replace deprecated
Color.value (flutter/packages#10480)
2025-11-20 [email protected] [google_maps_flutter] Replace
deprecated color APIs in platform interface (flutter/packages#10477)
2025-11-20 [email protected] Roll Flutter (stable) from
b45fa18 to f5a8537 (12 revisions) (flutter/packages#10478)
2025-11-20 [email protected] Roll Flutter from
de4be4f to 9f383e0 (21 revisions) (flutter/packages#10481)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App p: webview_flutter platform-android platform-ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants