measureText function Null safety

Size measureText(
  1. String textValue,
  2. TextStyle textStyle,
  3. [int? angle]

This method measures the size for given text and textstyle


Size measureText(String textValue, TextStyle textStyle, [int? angle]) {
  Size size;
  final TextPainter textPainter = TextPainter(
      textDirection: TextDirection.ltr,
      text: TextSpan(text: textValue, style: textStyle));

  if (angle != null) {
    final Rect rect = rotatedTextSize(textPainter.size, angle);
    size = Size(rect.width, rect.height);
  } else {
    size = Size(textPainter.width, textPainter.height);
  return size;