measureText function
Returns the soon-to-be rendered size of text via a TextPainter
scalar
should be the value from MediaQuery.of(context).textScaleFactor
Implementation
Size measureText({
required String text,
required double scalar,
required TextStyle? style,
}) {
final TextPainter textPainter = TextPainter(
text: TextSpan(text: text, style: style),
maxLines: 1,
textScaleFactor: scalar,
textDirection: TextDirection.ltr,
)..layout();
return textPainter.size;
}