textWidth function
Return the minWidth occupied by text in a single line
Implementation
double textWidth(String text, TextStyle style, {TextAlign textAlign = TextAlign.left}) {
var span = TextSpan(text: text, style: style);
var tp = TextPainter(maxLines: 1, textAlign: textAlign, textDirection: TextDirection.ltr, text: span);
tp.layout();
return tp.width;
}