I have a CustomPainter extending class. Until now, I paint only rectangles with some static text in it. Now I want to improve this a little bit and want that the user of my Flutter-App can edit this text.
I added a TextEditingController to my Object-Class and tried this:
TextField textField = TextField(
controller: object.textController,
);
textField.createRenderObject(context).paint;
textFieldPainter.paint(canvas, Offset.zero);
}
Unfortunaly, there is nothing like a textField.createRenderObject-Function in Flutter. So I look for a idea how I can get my a "controlled Text" working.
I also played around with TextSpan(). But I can’t set the Controller to this.
2
Answers
For me, the following solution fit: I built a function that checks if a click was done within the dimensions of the rectangle. If yes, a "properties dialog" opens (currently only the text) and here the text can now also be changed.
I know, this is only a workaround and not a real solution to my question, but maybe the approach helps one or the other.
The following steps are not the best solution , but you can try this solution.
Steps: