Skip to content

Clicking on an icon of a custom component (task item) to change its type (open/done) #249

Answered by osaxma
siuvoniazzi asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @siuvoniazzi

I had a similar use case before where the user can click on an image to replace it while preserving the node's data (e.g. index in the document). The main issue was: updating the node's data from the component.

While SuperEditor still doesn't provide any direct approach to the problem, having the BuildContext accessible (through ComponentContext of ComponentBuilder) makes the InheritedWidget approach a viable option. I implemented this approach using the Provider package which is just a sugarcoat for InheritedWidget.

Simply, I wrapped SuperEditor.custom with a Provider for a custom controller, and I accessed that controller inside the ComponentBuilder through the BuildContext

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@osaxma
Comment options

@siuvoniazzi
Comment options

Answer selected by siuvoniazzi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants