Lined Notebook

[Flutter] CustomPainter에서 Text 회전

by JungWook_

안녕하세요. CutomPainter에서 TextPainter()로 글자를 그릴 때 회전해서 그리는 방법입니다.

var textPainter = TextPainter()
..text = TextSpan(text: leftText, style: const TextStyle(color: Colors.black, fontSize: 18))
..textDirection = TextDirection.ltr
..textAlign = TextAlign.center
..layout();
canvas.save();
canvas.translate(0, size.height / 2 - textPainter.height / 2 - bottomSize / 2);
canvas.rotate(-2 * pi / 4);
textPainter.paint(canvas, const Offset(0, 0));
canvas.restore();
블로그의 프로필 사진

블로그의 정보

hongmono

JungWook_

활동하기