findMatchingTextStyle<T> static method
RegexPatternTextStyle<T> ?
findMatchingTextStyle<T>(
- String textPart,
- List<
RegexPatternTextStyle< ? partStyleListT> >
Implementation
static RegexPatternTextStyle<T>? findMatchingTextStyle<T>(
String textPart,
List<RegexPatternTextStyle<T>>? partStyleList,
) {
if (textPart.isEmpty || partStyleList == null || partStyleList.isEmpty) {
return null;
}
for (final style in partStyleList) {
final compiledPattern = _compiledPatternCache[style] ??= RegExp(
style.regexPattern,
caseSensitive: style.caseSensitive,
multiLine: style.multiLine,
);
if (compiledPattern.hasMatch(textPart)) {
return style;
}
}
return null;
}