calculateWidth method
Calculate the width of the string based on the given text style.
Implementation
double calculateWidth(TextStyle style) {
final textSpan = TextSpan(text: this, style: style);
final textPainter = TextPainter(
text: textSpan,
textDirection: TextDirection.ltr,
)..layout();
return textPainter.size.width;
}