addHighlight function
void
addHighlight(
- TextSelection selection, {
- int color = 0xFFFFCC00,
- required highlight_type type,
- required String sectionFileName,
- required ReaderBloc readerBloc,
Implementation
void addHighlight(TextSelection selection,
{int color = 0xFFFFCC00,
required highlight_type type,
required String sectionFileName,
required ReaderBloc readerBloc}) {
if (selection.baseOffset == -1) return;
final newHighlight = Highlight(
color: color,
baseOffset: selection.baseOffset,
extendOffset: selection.extentOffset,
type: type);
readerBloc.highlights.add(
newHighlight,
);
readerBloc.highlights.sort((a, b) => a.compareTo(b));
print(readerBloc.highlights.last);
readerBloc.saveHighlights();
}