highlightMatches method

String highlightMatches(
  1. String text,
  2. Pattern pattern
)

Highlights occurrences of pattern within text using the theme's highlight color.

Implementation

String highlightMatches(String text, Pattern pattern) {
  return text.replaceAllMapped(pattern, (match) {
    return '${theme.highlight}${match.group(0)}${theme.reset}';
  });
}