calculateTextWidth function

double calculateTextWidth(
  1. String text,
  2. TextStyle style
)

Implementation

double calculateTextWidth(String text, TextStyle style) {
  final textPainter = TextPainter(
    text: TextSpan(text: text, style: style),
    textDirection: TextDirection.ltr,
  )..layout();
  return textPainter.size.width;
}