@@ -704,6 +704,87 @@ void main() {
704704 ]);
705705 });
706706
707+ test ('stroke-width with invalid value' , () {
708+ const String svg =
709+ '<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><path d="M100 10 H180 V90 H100 Z" fill="#ff0000" stroke="#0000ff" stroke-width="invalid"/></svg>' ;
710+
711+ final VectorInstructions instructions = parseWithoutOptimizers (svg);
712+
713+ expect (instructions.paints, const < Paint > [
714+ Paint (
715+ stroke: Stroke (color: Color (0xff0000ff )),
716+ fill: Fill (color: Color (0xffff0000 ))),
717+ ]);
718+
719+ expect (instructions.paths, < Path > [
720+ Path (
721+ commands: const < PathCommand > [
722+ MoveToCommand (100.0 , 10.0 ),
723+ LineToCommand (180.0 , 10.0 ),
724+ LineToCommand (180.0 , 90.0 ),
725+ LineToCommand (100.0 , 90.0 ),
726+ CloseCommand (),
727+ ],
728+ ),
729+ ]);
730+ });
731+
732+ test ('stroke-width with unit value' , () {
733+ const SvgTheme theme = SvgTheme ();
734+ const double ptConversionFactor = 96 / 72 ;
735+
736+ const String svg_px =
737+ '<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><path d="M100 10 H180 V90 H100 Z" fill="#ff0000" stroke="#0000ff" stroke-width="1px"/></svg>' ;
738+ const String svg_pt =
739+ '<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><path d="M100 10 H180 V90 H100 Z" fill="#ff0000" stroke="#0000ff" stroke-width="1pt"/></svg>' ;
740+ const String svg_ex =
741+ '<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><path d="M100 10 H180 V90 H100 Z" fill="#ff0000" stroke="#0000ff" stroke-width="1ex"/></svg>' ;
742+ const String svg_em =
743+ '<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><path d="M100 10 H180 V90 H100 Z" fill="#ff0000" stroke="#0000ff" stroke-width="1em"/></svg>' ;
744+ const String svg_rem =
745+ '<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><path d="M100 10 H180 V90 H100 Z" fill="#ff0000" stroke="#0000ff" stroke-width="1rem"/></svg>' ;
746+
747+ final VectorInstructions instructionsPx = parseWithoutOptimizers (svg_px);
748+ final VectorInstructions instructionsPt = parseWithoutOptimizers (svg_pt);
749+ final VectorInstructions instructionsEx = parseWithoutOptimizers (svg_ex);
750+ final VectorInstructions instructionsEm = parseWithoutOptimizers (svg_em);
751+ final VectorInstructions instructionsRem = parseWithoutOptimizers (svg_rem);
752+
753+ expect (instructionsPx.paints, < Paint > [
754+ const Paint (
755+ stroke: Stroke (color: Color (0xff0000ff ), width: 1.0 ),
756+ fill: Fill (color: Color (0xffff0000 ))),
757+ ]);
758+
759+ expect (instructionsPt.paints, < Paint > [
760+ const Paint (
761+ stroke:
762+ Stroke (color: Color (0xff0000ff ), width: 1 * ptConversionFactor),
763+ fill: Fill (color: Color (0xffff0000 ))),
764+ ]);
765+
766+ expect (instructionsEx.paints, < Paint > [
767+ Paint (
768+ stroke: Stroke (
769+ color: const Color (0xff0000ff ), width: 1.0 * theme.xHeight),
770+ fill: const Fill (color: Color (0xffff0000 ))),
771+ ]);
772+
773+ expect (instructionsEm.paints, < Paint > [
774+ Paint (
775+ stroke: Stroke (
776+ color: const Color (0xff0000ff ), width: 1.0 * theme.fontSize),
777+ fill: const Fill (color: Color (0xffff0000 ))),
778+ ]);
779+
780+ expect (instructionsRem.paints, < Paint > [
781+ Paint (
782+ stroke: Stroke (
783+ color: const Color (0xff0000ff ), width: 1.0 * theme.fontSize),
784+ fill: const Fill (color: Color (0xffff0000 ))),
785+ ]);
786+ });
787+
707788 test ('Dashed path' , () {
708789 final VectorInstructions instructions = parseWithoutOptimizers (
709790 '''
0 commit comments