findRegex method
Implementation
void findRegex(RegExp regex, TextStyle? highlightStyle) {
final style =
highlightStyle ?? const TextStyle(backgroundColor: Colors.amberAccent);
searchHighlights.clear();
final searchText = text;
final matches = regex.allMatches(searchText);
for (final match in matches) {
searchHighlights.add(
SearchHighlight(start: match.start, end: match.end, style: style),
);
}
searchHighlightsChanged = true;
notifyListeners();
}