generateSearchAndReplaceHighlights method
Implementation
List<Positioned> generateSearchAndReplaceHighlights({
required Iterable<Match> matches,
required int wordWidth,
}) {
final List<Positioned> widgets = [];
for (int i = 0; i < matches.length; i++) {
final Match match = matches.elementAt(i);
final double offset =
(textController.text.substring(0, match.start).split('\n').length -
1) *
cellHeight;
widgets.add(
Positioned(
key: ValueKey('$searchText-$searchItemCurrentIndex-$i'),
top: offset,
left: utils.AffogatoConstants.lineNumbersColWidth +
utils.AffogatoConstants.lineNumbersGutterWidth +
charNumAtIndex(match.start, controllerText: textController.text) *
cellWidth -
2,
width: wordWidth * cellWidth + 2,
child: Container(
height: cellHeight,
width: wordWidth * cellWidth,
color: Colors.orange
.withOpacity(i == searchItemCurrentIndex ? 0.3 : 0.2),
),
),
);
if (i == searchItemCurrentIndex) currentItemOffset = offset;
}
return widgets;
}