Index: tools/gardening/lib/src/util.dart |
diff --git a/tools/gardening/lib/src/util.dart b/tools/gardening/lib/src/util.dart |
index f21703aba560c0d9c327e1afa43612dcc5ac5d86..51b50c1e3dec79d037401a16254d3a4046ee07ee 100644 |
--- a/tools/gardening/lib/src/util.dart |
+++ b/tools/gardening/lib/src/util.dart |
@@ -10,6 +10,18 @@ import 'package:args/args.dart'; |
import 'cache.dart'; |
+/// Checks that [haystack] contains substring [needle], case insensitive. |
+/// Throws an exception if either parameter is `null`. |
+bool containsIgnoreCase(String haystack, String needle) { |
+ if (haystack == null) { |
+ throw "Unexpected null as the first paramter value of containsIgnoreCase"; |
+ } |
+ if (needle == null) { |
+ throw "Unexpected null as the second parameter value of containsIgnoreCase"; |
+ } |
+ return haystack.toLowerCase().contains(needle.toLowerCase()); |
+} |
+ |
/// Split [text] using [infixes] as infix markers. |
List<String> split(String text, List<String> infixes) { |
List<String> result = <String>[]; |