format method
void
format()
Implementation
void format() {
String selectionText =
controller.text.substring(selection.start, selection.end);
beforeText = controller.text.substring(0, selection.start);
afterText =
controller.text.substring(selection.end, controller.text.length);
reversedBeforeText =
String.fromCharCodes(beforeText.runes.toList().reversed);
reversedAfterText = String.fromCharCodes(afterText.runes.toList().reversed);
character = multipleCharacters != null
? multipleCharacters![multipleCharactersOption ?? 0]
: character ?? '';
if (controller.text.isNotEmpty && selectionText.isNotEmpty) {
newText = selectionText;
if (selectionCharacterBool(
formatOption: formatOption, selectionText: selectionText)) {
selectionHasCharacterFunction(formatOption: formatOption);
} else if (outsideSelectionHasCharacterBool(formatOption: formatOption)) {
outsideHasCharacterFunction(formatOption: formatOption);
} else {
addFunction(formatOption: formatOption);
}
applyFunction(formatOption: formatOption);
} else {
emptyAddNewFunction(formatOption: formatOption);
}
}