如何计算文字长度

2018/08/13 posted in  Flutter
Text t = Text("hello world");
TextPainter textPainter = TextPainter(
   textDirection: TextDirection.ltr,
   text: t.textSpan,
).layout();
double width = textPainter.width;