Open m-1226 opened 1 month ago
You can get the content length with the following code:
int getContentLength() {
return quillController.document.toPlainText().trimRight().length;
}
Then add a totalListener to the quillController:
ValueNotifier<int> total = ValueNotifier(0);
void totalListener() {
WidgetsBinding.instance.addPostFrameCallback((_) {
total.value = getContentLength();
});
}
Register this Listener in initState():
@override
void initState() {
super.initState();
quillController.addListener(totalListener);
}
and dispose:
@override
void dispose() {
quillController.removeListener(totalListener);
quillController.dispose();
super.dispose();
}
This way you can get the number of characters in real time
thank you worked for me
Is there an existing issue for this?
The question
how to I set a word counter for the editor and when it exceed it it highlight it as red color?