Package
vector_graphics_compiler
Problem
Follow-up to flutter/packages#11619 and #185833.
The previous fix corrected decimal percentage handling in legacy hsl() / hsla() color parsing. During review, maintainers suggested two follow-up improvements:
- Move HSL parsing out of
parser.dart into colors.dart, similar to the existing RGB parsing path, so HSL can share the same parser organization and support both legacy and modern syntax.
Optional, doesn't need to be part of this PR, but an idea for another potential improvement:
If we move the hsl code to a parseHslFunction in colors.dart similar to this parseRgbFunction, that could enable us to support both legacy and modern css style color strings "hsla(H, S, L, A)" and "hsla(H S L A)" the way we do for rgb in colors.dart.
flutter/packages#11619 (comment)
- Add explicit tests for alpha clamp behavior introduced by the HSL alpha parsing fix.
I like that you've added clamps. Please consider adding tests for values which would be clamped
flutter/packages#11619 (comment)
Proposed change
- Add
parseCssHsl and parseHslFunction to colors.dart, following the existing parseCssRgb / parseRgbFunction structure.
- Keep this scoped to the same practical numeric subset supported by the current RGB parser rather than implementing the full CSS Color 4 grammar.
- Support both:
- legacy comma-separated HSL/HSLA syntax, e.g.
hsl(270, 100%, 76%)
- modern space-separated HSL/HSLA syntax, e.g.
hsl(270 100% 76% / 0.5)
- Add tests for valid/invalid HSL syntax variants and HSLA alpha clamping.
Notes
This is not intended to be a complete CSS Color 4 parser. For example, angle hue units, none, calc(), and relative color syntax remain out of scope, matching the existing RGB parser's regex-based subset approach.
Package
vector_graphics_compiler
Problem
Follow-up to flutter/packages#11619 and #185833.
The previous fix corrected decimal percentage handling in legacy
hsl()/hsla()color parsing. During review, maintainers suggested two follow-up improvements:parser.dartintocolors.dart, similar to the existing RGB parsing path, so HSL can share the same parser organization and support both legacy and modern syntax.Proposed change
parseCssHslandparseHslFunctiontocolors.dart, following the existingparseCssRgb/parseRgbFunctionstructure.hsl(270, 100%, 76%)hsl(270 100% 76% / 0.5)Notes
This is not intended to be a complete CSS Color 4 parser. For example, angle hue units,
none,calc(), and relative color syntax remain out of scope, matching the existing RGB parser's regex-based subset approach.