the solution from @zealous-system is great, but sometimes the text(1 or 2 letters) moves to the second line because of rounding, so instead of using constraints.maxWidth, you can create a variable maxWidth = constraints.maxWidth - 10