contains static method

bool contains(
  1. String haystack,
  2. dynamic needles, {
  3. bool ignoreCase = false,
})

Determines if haystack contains any of the needles.

Implementation

static bool contains(
  String haystack,
  dynamic needles, {
  bool ignoreCase = false,
}) {
  final h = ignoreCase ? haystack.toLowerCase() : haystack;
  final list = needles is List ? needles : [needles];
  for (final n in list) {
    final s = ignoreCase ? n.toString().toLowerCase() : n.toString();
    if (s.isNotEmpty && h.contains(s)) return true;
  }
  return false;
}