Flutter 颤振:如何将CustomPainter绘图导出/保存为字符串坐标或图像base64?
我有一个CustomPainter,用户必须在图像上绘制多条指向不同事物的线。我需要将所有这些行导出到字符串数组或image base64。这可能吗? 我的代码如下:Flutter 颤振:如何将CustomPainter绘图导出/保存为字符串坐标或图像base64?,flutter,canvas,base64,export,paint,Flutter,Canvas,Base64,Export,Paint,我有一个CustomPainter,用户必须在图像上绘制多条指向不同事物的线。我需要将所有这些行导出到字符串数组或image base64。这可能吗? 我的代码如下: class Signature extends CustomPainter { List<Offset> points; Signature({this.points}); @override void paint(Canvas canvas, Size size) { Paint paint
class Signature extends CustomPainter {
List<Offset> points;
Signature({this.points});
@override
void paint(Canvas canvas, Size size) {
Paint paint = new Paint()
..color = Colors.black
..strokeCap = StrokeCap.round
..strokeWidth = 5.0;
for (int i = 0; i < points.length - 1; i++) {
if (points[i] != null && points[i + 1] != null) {
canvas.drawLine(points[i], points[i + 1], paint);
}
canvas.clipRect(Offset.zero & size);
}
}
@override
bool shouldRepaint(Signature oldDelegate) => oldDelegate.points != points;
}
类签名扩展了CustomPainter{
列出要点;
签名({this.points});
@凌驾
空心油漆(帆布,尺寸){
油漆=新油漆()
…颜色=颜色
..strokeCap=strokeCap.round
..冲程宽度=5.0;
对于(int i=0;ioldDelegate.points!=点;
}