packages icon indicating copy to clipboard operation
packages copied to clipboard

[vector_graphics_compiler] support percentage units SVG shape attributes

Open stevenctl opened this issue 2 weeks ago • 0 comments

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

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.

stevenctl avatar Dec 06 '25 15:12 stevenctl