buildNoTapHighlight static method
Implementation
static Widget buildNoTapHighlight({
required String text,
String highlightText = "",
required TextStyle textStyle,
required TextStyle highlightStyle,
int maxLines = 1,
TextOverflow overflow = TextOverflow.ellipsis,
}) {
if (highlightText.isEmpty) {
return Text(text, maxLines: maxLines, overflow: overflow, style: textStyle);
}
List<TextSpan> spans = text.characters.map((char) {
bool isHighlighted = highlightText.toLowerCase().contains(char.toLowerCase());
return TextSpan(text: char, style: isHighlighted ? highlightStyle : textStyle);
}).toList();
return RichText(
maxLines: maxLines,
overflow: overflow,
text: TextSpan(children: spans),
);
}