-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[vector_graphics_compiler] fix: handle parsing stroke-width with an invalid value #8004
Changes from 2 commits
878304b
a14a296
27c5129
d23b800
75aba47
8d754b7
94f6168
71830ee
6fbe33b
7cd5021
4aa435c
5783843
a69d531
e103432
724c7b9
49a8855
66d11b4
8a1440f
7674b9b
141c99a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 1.1.13 | ||
|
||
* Fixes an issue when parse double with 'none' value | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "when parsing a double with a value of 'none'." |
||
|
||
## 1.1.12 | ||
|
||
* Transfers the package source from https://github.com/dnfield/vector_graphics | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,7 @@ import 'theme.dart'; | |
/// which is stripped off when parsed to a `double`. | ||
/// | ||
/// Passing `null` will return `null`. | ||
double? parseDouble(String? rawDouble, {bool tryParse = false}) { | ||
assert(tryParse != null); // ignore: unnecessary_null_comparison | ||
double? parseDouble(String? rawDouble) { | ||
if (rawDouble == null) { | ||
return null; | ||
} | ||
|
@@ -26,10 +25,7 @@ double? parseDouble(String? rawDouble, {bool tryParse = false}) { | |
.replaceFirst('pt', '') | ||
.trim(); | ||
|
||
if (tryParse) { | ||
return double.tryParse(rawDouble); | ||
} | ||
return double.parse(rawDouble); | ||
return double.tryParse(rawDouble); | ||
} | ||
|
||
/// Convert [degrees] to radians. | ||
|
@@ -81,7 +77,6 @@ double? parseDoubleWithUnits( | |
} | ||
final double? value = parseDouble( | ||
rawDouble, | ||
tryParse: tryParse, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i will check it |
||
); | ||
|
||
return value != null ? value * unit : null; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,6 +172,10 @@ void main() { | |
expect(parseDoubleWithUnits('1pt', theme: const SvgTheme()), 1 + 1 / 3); | ||
}); | ||
|
||
test('"none" conversion', () { | ||
expect(parseDoubleWithUnits('none', theme: const SvgTheme()), null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is testing the specific change to the parsing function, but isn't testing anything related to the original issue. It's not at all clear from the change and the test what actually happens now in the original case of the issue this PR is intended to fix. Does returning null instead of throwing work, or does it just create a different issue elsewhere in that codepath? If the goal is to fix the case of an SVG with percentage values or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hi @stuartmorgan , what kind of test cases need to be added, do you have any suggestions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You provided an SVG that triggered this error in a comment above; a test that parsed a minimal version of that SVG and ensured that it behaved as expected seems like it would give good coverage of this use case. |
||
}); | ||
|
||
test('Parse a transform with scientific notation', () { | ||
expect( | ||
parseTransform('translate(9e-6,6.5e-4)'), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing a period; see the PR checklist link for CHANGELOG style.