getTextPainterLaidout function

TextPainter getTextPainterLaidout({
  1. required BuildContext context,
  2. required String text,
  3. TextStyle? style,
  4. TextScaler? textScaler,
})

Implementation

TextPainter getTextPainterLaidout({
  required BuildContext context,
  required String text,
  TextStyle? style,
  TextScaler? textScaler,
}) {
  textScaler ??= TextScaler.linear(
    View.of(context).platformDispatcher.textScaleFactor,
  );
  final TextPainter textPainter = TextPainter(
    text: TextSpan(text: text, style: style),
    textDirection: TextDirection.ltr,
    textScaler: textScaler,
  );
  textPainter.layout();
  return textPainter;
}