flutter-quill icon indicating copy to clipboard operation
flutter-quill copied to clipboard

How to append text to the end of a document

Open garth-waters opened this issue 1 year ago • 1 comments

Is there an existing issue for this?

The question

Thanks for a great product.

How do I append text to the end of the document, without changing the position of the current scroll position?

Many Thanks Garth

garth-waters avatar Jan 12 '24 14:01 garth-waters

//move cursor to end controller.moveCursorToEnd(); //get the offset int offset = getCursorOffset(controller); //create a delta from text final doc = Document.fromHtml("normal text also works"); // create the delta from document block = doc.toDelta();

//add at the position (which is end) (replace text with zero size adds the content) controller.replaceText( offset, 0, block, TextSelection.collapsed(offset: offset));

dawarepramod4 avatar Mar 19 '24 16:03 dawarepramod4