Skip to content
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

feat: remove unnecessary 'tryParse' on parseDouble #257

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions packages/vector_graphics_compiler/lib/src/svg/numbers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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.
Expand Down Expand Up @@ -81,7 +77,6 @@ double? parseDoubleWithUnits(
}
final double? value = parseDouble(
rawDouble,
tryParse: tryParse,
);

return value != null ? value * unit : null;
Expand Down