I have not worked with canvas in flutter but I think that edit text box like the one in the image can be achieved by canvas. The background expands with the text length and if the text length in a line is 0 then there is no background.
If you have any code or suggestions to do so, then please help.
Here the code:
The strokeWidth should be larger than the fontSize to fill all the text by the color you choose.
Try to play with it so that you end up with more accurate result.