[vector_graphics_compiler] support percentage units SVG shape attributes
Adds percentage unit support for SVG shape attributes
SVG shapes like <rect>, <circle>, <ellipse>, and <line> can have percentage values for their position and size attributes (e.g., width="50%", cx="50%"). Previously
these weren't handled correctly. Easy to test with any image like https://placeholdit.com/600x400/dddddd/999999
This adds:
- Percentage parsing in parseDoubleWithUnits that resolves values against the viewport dimensions
- Viewport width/height getters on SvgParser
- Proper percentage reference handling for all basic shape elements
- Circle radius uses the normalized diagonal per SVG spec
List which issues are fixed by this PR. You must list at least one issue.
I'm not sure if it fixes these issues, as they have no description. I can file a new issue if needed.
https://github.com/flutter/flutter/issues/158844 https://github.com/flutter/flutter/issues/158845
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.