avgCharSize property

Size get avgCharSize

Implementation

Size get avgCharSize {
  TextStyle textStyle = TextStyle(
    fontFamilyFallback: renderStyle.fontFamily,
    fontSize: renderStyle.fontSize.computedValue,
    textBaseline: CSSText.getTextBaseLine(),
    package: CSSText.getFontPackage(),
    locale: CSSText.getLocale(),
  );
  TextPainter painter = TextPainter(
    text: TextSpan(
      text: '0',
      style: textStyle,
    ),
    textDirection: TextDirection.ltr
  );
  painter.layout();

  List<LineMetrics> lineMetrics = painter.computeLineMetrics();

  return Size(lineMetrics[0].width, lineMetrics[0].height);
}