diff --git a/sdk/lib/_internal/vm_shared/lib/bool_patch.dart b/sdk/lib/_internal/vm_shared/lib/bool_patch.dart index 24f1d0c20d83..15e5309a0006 100644 --- a/sdk/lib/_internal/vm_shared/lib/bool_patch.dart +++ b/sdk/lib/_internal/vm_shared/lib/bool_patch.dart @@ -25,31 +25,47 @@ class bool { @patch static bool parse(String source, {bool? caseSensitive}) { - checkNotNullable(source, "source"); + checkNotNullable(source, "source"); //The caseSensitive defaults to true. - if (caseSensitive == null || caseSensitive == true) - return source == "true" ? true : source == "false" ? false : throw ArgumentError(source); - //Ignore case-sensitive when caseSensitive is false. - return _compareIgnoreCase(source, "true")? true : _compareIgnoreCase(source, "false")? false : throw ArgumentError(source); + if (caseSensitive == null || caseSensitive == true) + return source == "true" + ? true + : source == "false" + ? false + : throw ArgumentError(source); + //Ignore case-sensitive when caseSensitive is false. + return _compareIgnoreCase(source, "true") + ? true + : _compareIgnoreCase(source, "false") + ? false + : throw ArgumentError(source); } @patch static bool? tryParse(String source, {bool? caseSensitive}) { - checkNotNullable(source, "source"); + checkNotNullable(source, "source"); //The caseSensitive defaults to true. - if (caseSensitive == null || caseSensitive == true) - return source == "true" ? true : source == "false" ? false : null; - //Ignore case-sensitive when caseSensitive is false. - return _compareIgnoreCase(source, "true")? true : _compareIgnoreCase(source, "false")? false : null; + if (caseSensitive == null || caseSensitive == true) + return source == "true" + ? true + : source == "false" + ? false + : null; + //Ignore case-sensitive when caseSensitive is false. + return _compareIgnoreCase(source, "true") + ? true + : _compareIgnoreCase(source, "false") + ? false + : null; } static bool _compareIgnoreCase(String input, String lowerCaseTarget) { - if (input.length != lowerCaseTarget.length) return false; - for (var i = 0; i < input.length; i++) { - if (input.codeUnitAt(i) | 0x20 != lowerCaseTarget.codeUnitAt(i)) { - return false; - } - } - return true; + if (input.length != lowerCaseTarget.length) return false; + for (var i = 0; i < input.length; i++) { + if (input.codeUnitAt(i) | 0x20 != lowerCaseTarget.codeUnitAt(i)) { + return false; + } + } + return true; } }