measureText static method
Measures the size of text with the given style.
Implementation
static Size measureText(String text, TextStyle style, {double? maxWidth}) {
final textSpan = TextSpan(text: text, style: style);
final textPainter = TextPainter(
text: textSpan,
textDirection: TextDirection.ltr,
maxLines: maxWidth != null ? null : 1,
);
textPainter.layout(maxWidth: maxWidth ?? double.infinity);
return Size(textPainter.width, textPainter.height);
}