textSize method

Size textSize({
  1. required TextStyle? style,
  2. int maxLines = 1,
  3. double maxWidth = double.infinity,
})

Implementation

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