From fd3e5a2a95352d67b2c8d52f24610fdc7e4ff2c6 Mon Sep 17 00:00:00 2001 From: fransdhinta Date: Thu, 3 Oct 2024 13:31:01 +0700 Subject: [PATCH] feat: remove unnecessary 'tryParse' on parseDouble --- .../vector_graphics_compiler/lib/src/svg/numbers.dart | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/vector_graphics_compiler/lib/src/svg/numbers.dart b/packages/vector_graphics_compiler/lib/src/svg/numbers.dart index fbe7563b..05c34e0b 100644 --- a/packages/vector_graphics_compiler/lib/src/svg/numbers.dart +++ b/packages/vector_graphics_compiler/lib/src/svg/numbers.dart @@ -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, ); return value != null ? value * unit : null;