replaceMistake method
Replaces mistake with given replacement
Implementation
void replaceMistake(Mistake mistake, String replacement) {
final mistakes = List<Mistake>.from(_mistakes);
mistakes.remove(mistake);
_mistakes = mistakes;
text = text.replaceRange(mistake.offset, mistake.endOffset, replacement);
focusNode?.requestFocus();
Future.microtask.call(() {
final newOffset = mistake.offset + replacement.length;
selection = TextSelection.fromPosition(TextPosition(offset: newOffset));
});
}