getTextSize static method

Size getTextSize(
  1. String? text,
  2. TextStyle? style
)

Implementation

static Size getTextSize(String? text, TextStyle? style) {
  final TextPainter textPainter = TextPainter(
      text: TextSpan(text: text, style: style),
      maxLines: 1,
      textDirection: TextDirection.ltr)
    ..layout(minWidth: 0, maxWidth: double.infinity);
  return textPainter.size;
}