measureText static method
Measures the width of a string with the given style and context.
Implementation
static double measureText(BuildContext context, String text, TextStyle style) {
final textPainter = TextPainter(
text: TextSpan(text: text, style: style),
maxLines: 1,
textDirection: TextDirection.ltr,
textScaler: MediaQuery.textScalerOf(context),
)..layout();
return textPainter.width;
}