flutter_html_css_color 0.2.0
flutter_html_css_color: ^0.2.0 copied to clipboard
A flutter_html extension that corrects the CSS colours flutter_html 3.0.0 mis-reads or drops: 8-digit hex, hsl(), the space-separated syntax, hwb() and 148 named colours.
0.2.0 #
- Renamed from
flutter_html_css_color_extensionon pub.flutter-io.cn. The old package stays published and is marked discontinued with this one as its replacement. Class names are unchanged.
0.1.0 #
- Initial release.
flutter_html3.0.0 gets a surprising amount of CSS colour wrong and says nothing about it. An 8-digit#rrggbbaais read as a Dart0xAARRGGBBliteral, so every channel lands one place along and#00ff0040comes out invisible;#rgbais worse, because only the 3-digit shorthand gets expanded. The space-separatedrgb(255 0 0)andrgb(255 0 0 / a)are dropped, so is a percentage channel, and an out-of-range one wraps instead of clamping.hsl()in that syntax renders black rather than falling back, and a hue outside 0 to 360 trips an assertion.hwb(),rebeccapurple,transparentandcurrentColorare dropped, andaliceblueis a saturated blue becausecsslibholds it as five hex digits. Twotext-shadowvalues throw a null-check error, in release as well as debug. All of it is measured and pinned;doc/colors.mdhas the table. - The fix is deliberately small: one rewrite of the inline
styleattribute at thepreStylingstep, into the legacyrgba(r, g, b, a)formflutter_htmlalready reads without loss. That reachescolor,background-color,borderand its four sides,text-decoration-colorandtext-shadowin one go, and it lands before the parser, which is the only place the two throwing values can be caught. - If you register
flutter_html_css_border_radiusas well, list this one before it. Both match at thepreStylingstep and run in registration order, and that package readsborderwith a colour parser of its own that knows six names and nohsl(). Listed second, aborder: 2px solid hsl(0 100% 50%)clip comes out black. border-color, theborder-*-colorlonghands, the logical border shorthands andoutlineget the same rewrite, even thoughflutter_htmlhas no case for them and drops the declaration whatever the token says. The reason is flutter_html_css_border, which folds those longhands into abordershorthand at the samepreStylingstep and passes the colour token through as written. With the longhands skipped, that fold carried a rawhsl()whenever this extension ran first, andflutter_htmlread it as black. Nowborder-color: hsl(0 100% 50%)comes out red in either order, and the order test pins both.