getTextWidth method

Size getTextWidth(
  1. TextStyle style,
  2. BuildContext context
)

Implementation

Size getTextWidth(TextStyle style, BuildContext context) {
  TextPainter textPainter = TextPainter(
      text: TextSpan(text: this, style: style),
      maxLines: 1,
      textScaleFactor: MediaQuery.of(context).textScaleFactor,
      textDirection: TextDirection.ltr)
    ..layout();
  return textPainter.size;
}