paintString static method
void
paintString(})
绘制字符串
point
绘制中点
text
显示文本
fontSize
文本大小
color
文本颜色
rotateAngle
旋转角度
Implementation
static void paintString(
Canvas canvas,
Offset point,
String text, {
double fontSize = 12,
Color color = Colors.black,
double rotateAngle = 0,
}) {
TextPainter textPainter = TextPainter(
textAlign: TextAlign.center, textDirection: TextDirection.rtl);
// 绘制标题
textPainter.text = TextSpan(
text: text,
style: TextStyle(
color: color, fontFamily: 'Times New Roman', fontSize: fontSize));
textPainter.layout();
canvas.save();
canvas.rotate(-rotateAngle);
textPainter.paint(
canvas,
Offset(point.dx - textPainter.width * 0.5,
point.dy - textPainter.height * 0.5));
canvas.restore();
}