flutter-quill
flutter-quill copied to clipboard
Trying to update table cells throws exception
Is there an existing issue for this?
- [X] I have searched the existing issues
The question
While I know I'm the one who created this feature, I did it in a rush and with quite a few bugs in the code. I'm currently fixing most of these so that the tables can be usable by all users.
However, one thing I haven't been able to figure out is how to consistently update the tables once they're already embedded. I tried using the example code in custom_embed_blocks but to no avail. The getEmbedNode method never finds the table.
So far, this is the code that is responsible for updating the tables (it's a bit different as I wanted it to be easier to understand):
void _updateTable() {
final delta = Delta()
..insert({'table': _tableModel.toMap()})
..insert('\n');
final block = BlockEmbed.custom( CustomTableEmbed.fromDocument(Document.fromDelta(delta)), );
final offset = getEmbedNode(widget.controller, widget.controller.selection.start).offset;
widget.controller.replaceText(offset, 1, block, TextSelection.collapsed(offset: offset));
}