Add A Prefix To Every Line In A Multiline Text Input In Flutter?
I wanted to know if there was a way of adding a prefix (like '- ') to every line in a multiline Text Input in Flutter. For example: Hello World! Would become: -Hello -World! This i
Solution 1:
U can add a -
everytime a new line is created.
Add this in your initState(),
final prefix = '-';
_elementsContoller.addListener(() {
if(_elementsController.text.endsWith('\n')) {
// Add the prefix everytime a new line is created
_elementsController.text += prefix;
}
}
If these changes should be made after the input,
text.replaceAll('\n', '\n$prefix');
Post a Comment for "Add A Prefix To Every Line In A Multiline Text Input In Flutter?"