Skip to content

[webview_flutter_wkwebview] Fixes lossless transition from Dart Color to native UIColor when calling setBackgroundColor#10610

Merged
auto-submit[bot] merged 9 commits intoflutter:mainfrom
bparrishMines:wk_uicolor
Feb 27, 2026
Merged

[webview_flutter_wkwebview] Fixes lossless transition from Dart Color to native UIColor when calling setBackgroundColor#10610
auto-submit[bot] merged 9 commits intoflutter:mainfrom
bparrishMines:wk_uicolor

Conversation

@bparrishMines
Copy link
Contributor

@bparrishMines bparrishMines commented Dec 11, 2025

Fixes flutter/flutter#178870

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

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

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 updates the webview_flutter_wkwebview package to use UIColor for setting background colors instead of an integer representation, which is a good improvement for type safety and correctness. However, I've found a critical issue in the Dart code where Color properties are accessed incorrectly (.r, .g, etc. instead of .red, .green, etc.) and not normalized for the UIColor constructor. This will cause compilation errors. I've provided suggestions to fix this in the implementation and the tests. Additionally, a test case for setBackgroundColor was commented out, which I've suggested to re-enable with the necessary fixes.

@stuartmorgan-g
Copy link
Collaborator

From triage: still something we plan to get back to, just not currently active.

@bparrishMines bparrishMines marked this pull request as ready for review February 26, 2026 20:21
@bparrishMines bparrishMines changed the title updated source code [webview_flutter_wkwebview] Fixes lossless transition from Dart Color to native UIColor when calling setBackgroundColor Feb 26, 2026
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 aims to fix a lossy color transition by using a UIColor proxy instead of an integer representation. While the overall approach is correct, there's a critical issue in the implementation. The color components from Dart's Color object (which are integers from 0-255) are being passed directly to the UIColor constructor, which expects double values normalized to the range [0.0, 1.0]. This will result in incorrect colors being displayed. I've added suggestions to normalize these values by dividing by 255.0. The corresponding tests also need to be updated to check for these normalized values.

Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

LGTM

let red = 0.5
let green = 0.5
let blue = 0.5
let alpha = 0.5
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should use different values for each component; this test would pass even if we had a typo somewhere that swapped colors around.

@@ -1,3 +1,7 @@
## 3.23.8

* Fixes lossless transition from Dart Color to native UIColor when calling `setBackgroundColor`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: what it fixes is a potentially lossy transition; the fix is that it's now lossless. So it should be "Fixes lossy transition ..." or "Uses lossless conversion ..."

@bparrishMines bparrishMines added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 27, 2026
@auto-submit auto-submit bot merged commit 7f9860a into flutter:main Feb 27, 2026
81 checks passed
@bparrishMines bparrishMines deleted the wk_uicolor branch February 27, 2026 21:42
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 2, 2026
…Dart Color to native UIColor when calling `setBackgroundColor` (flutter/packages#10610)
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Mar 2, 2026
flutter/packages@a27d7c5...faa4e22

2026-03-02 49699333+dependabot[bot]@users.noreply.github.com
[dependabot]: Bump the test-dependencies group across 14 directories
with 1 update (flutter/packages#11152)
2026-02-28 [email protected] [pigeon] Reduce reply-handling
duplication in generated Dart code. (flutter/packages#11114)
2026-02-27 [email protected]
[webview_flutter_wkwebview] Fixes lossless transition from Dart Color to
native UIColor when calling `setBackgroundColor`
(flutter/packages#10610)
2026-02-27 [email protected] Roll Flutter from
b31548f to 1141b2b (56 revisions) (flutter/packages#11137)

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
xxxOVALxxx pushed a commit to xxxOVALxxx/flutter that referenced this pull request Mar 10, 2026
…r#183117)

flutter/packages@a27d7c5...faa4e22

2026-03-02 49699333+dependabot[bot]@users.noreply.github.com
[dependabot]: Bump the test-dependencies group across 14 directories
with 1 update (flutter/packages#11152)
2026-02-28 [email protected] [pigeon] Reduce reply-handling
duplication in generated Dart code. (flutter/packages#11114)
2026-02-27 [email protected]
[webview_flutter_wkwebview] Fixes lossless transition from Dart Color to
native UIColor when calling `setBackgroundColor`
(flutter/packages#10610)
2026-02-27 [email protected] Roll Flutter from
b31548f to 1141b2b (56 revisions) (flutter/packages#11137)

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-ios platform-macos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[webview_flutter] Make iOS background lossless

2 participants