calculateTextHeight static method
double
calculateTextHeight(
- BuildContext context,
- String value,
- dynamic fontSize,
- FontWeight fontWeight,
- double maxWidth,
- int maxLines,
Implementation
static double calculateTextHeight(BuildContext context, String value,
fontSize, FontWeight fontWeight, double maxWidth, int maxLines) {
value = filterText(value);
TextPainter painter = TextPainter(
///AUTO:华为手机如果不指定locale的时候,该方法算出来的文字高度是比系统计算偏小的。
locale: Localizations.localeOf(context),
maxLines: maxLines,
textDirection: TextDirection.ltr,
text: TextSpan(
text: value,
style: TextStyle(
fontWeight: fontWeight,
fontSize: fontSize,
)));
painter.layout(maxWidth: maxWidth);
///文字的宽度:painter.width
return painter.height;
}