[vector_graphics_compiler] Fix rgb/rgba color parsing to support modern CSS syntax
- Consolidate rgb() and rgba() parsing into single implementation
- Add support for space-separated color values
- Add support for percentage-based RGB values
- Add support for slash (/) separator before alpha channel
- Handle both comma and space delimiters
- Add comprehensive test coverage for various color formats
This PR solves https://github.com/flutter/flutter/issues/179261
Pre-Review Checklist
- [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
- [x] I read the Tree Hygiene page, which explains my responsibilities.
- [x] I read and followed the relevant style guides and ran the auto-formatter.
- [x] I signed the CLA.
- [x] The title of the PR starts with the name of the package surrounded by square brackets, e.g.
[shared_preferences] - [x] I linked to at least one issue that this PR fixes in the description above.
- [x] I updated
pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under[^1]. - [x] I updated
CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under[^1]. - [x] I updated/added any relevant documentation (doc comments with
///). - [x] I added new tests to check the change I am making, or I have commented below to indicate which test exemption this PR falls under[^1].
- [x] All existing and new tests are passing.
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.
[^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.
- [ ] I linked to at least one issue that this PR fixes in the description above.
- [ ] I updated
pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.
Thanks for the contribution! Once you've completed the checklist, please mark the PR as ready for review.
- [x] I updated
CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.
Please make sure to follow the linked style guide.
@stuartmorgan-g Completed the checklist. This is my first PR to any flutter/dart repo. If anything is not exactly correct, please let me know and I'll address.
Ping @stuartmorgan-g . Any chance we can get this fix reviewed/merged?
I can do an initial review, but this will need a review from the engine team. Review capacity tends to be low in December, which is probably why this hasn't been picked up yet.
Thank you for the review @stuartmorgan-g . I completely re-wrote to a fresh implementation that checks strictly for the format and handles correctly all the cases (including weird ones such as R G,B,A -- where R G are space delimited) that seem to work on web.
I also added tests for a lot of invalid cases.
Bonus: I also added handling for
-
R,G,Bvalues being double instead of int (which seems to be supported on web). - Values being out of bounds, which just clamp to the bounds on web rather than failing to parse
/gemini review