我想写一个小工具上面的文本有参数画图,这需要画图()。此小部件在图形节点之间绘制边,并且它不接受任何参数作为TextPaint()。
发布于 2021-08-15 13:36:38
下面是一个在CustomPainter或CustomDecoration中绘制文本的示例。您需要做的就是在画布上使用TextPainter。
final textPainter = TextPainter(
text: TextSpan(
text: 'Foo\nBar',
style: TextStyle(
color: Colors.black,
fontSize: 30,
),
),
textDirection: TextDirection.ltr,
textAlign: TextAlign.center
);
textPainter.layout();
// Draw the text centered around the point (50, 100) for instance
final offset = Offset(50 - (textPainter.width / 2), 100 - (textPainter.height / 2));
textPainter.paint(canvas, offset);https://stackoverflow.com/questions/64184263
复制相似问题