highlightSearchTerm static method

String highlightSearchTerm(
  1. String text,
  2. String searchTerm
)

Função para destacar texto encontrado (útil para UI)

Implementation

static String highlightSearchTerm(String text, String searchTerm) {
  if (searchTerm.isEmpty) return text;

  final regex = RegExp(searchTerm, caseSensitive: false);
  return text.replaceAllMapped(regex, (match) => '**${match.group(0)}**');
}