diff --git a/packages/vector_graphics_compiler/lib/src/svg/parsers.dart b/packages/vector_graphics_compiler/lib/src/svg/parsers.dart index a8e3a77c..fc7e2b1f 100644 --- a/packages/vector_graphics_compiler/lib/src/svg/parsers.dart +++ b/packages/vector_graphics_compiler/lib/src/svg/parsers.dart @@ -29,23 +29,26 @@ List _parseTransformParams(String params) { final List result = []; String current = ''; for (int i = 0; i < params.length; i += 1) { - if (params[i] == ' ' || params[i] == '-' || params[i] == ',') { + final String char = params[i]; + final bool isSeparator = char == ' ' || char == '-' || char == ','; + final bool isExponent = i > 0 && params[i - 1] == 'e'; + if (isSeparator && !isExponent) { if (current != '') { result.add(parseDouble(current)!); } - if (params[i] == '-') { + if (char == '-') { current = '-'; } else { current = ''; } } else { - if (params[i] == '.') { + if (char == '.') { if (current.contains('.')) { result.add(parseDouble(current)!); current = ''; } } - current += params[i]; + current += char; } } if (current.isNotEmpty) { diff --git a/packages/vector_graphics_compiler/test/parsers_test.dart b/packages/vector_graphics_compiler/test/parsers_test.dart index d490cdf9..67003f1e 100644 --- a/packages/vector_graphics_compiler/test/parsers_test.dart +++ b/packages/vector_graphics_compiler/test/parsers_test.dart @@ -173,6 +173,13 @@ void main() { expect(parseDoubleWithUnits('1pt', theme: const SvgTheme()), 1 + 1 / 3); }); + test('Parse a transform with scientific notation', () { + expect( + parseTransform('translate(9e-6,6.5e-4)'), + AffineMatrix.identity.translated(9e-6, 6.5e-4), + ); + }); + test('Parse a transform with a missing space', () { expect( parseTransform('translate(0-70)'),