我做了一个屏幕,用户可以使用image_painter在图像周围绘制,它工作得很好。现在我希望能够保存用户绘制的线的路径,但无论我如何搜索,我什么也找不到。
我怎么能这么做?我还尝试添加手势,但没有效果,这样的库没有保存路径的选项,这对我来说似乎很奇怪
import 'package:flutter/material.dart';
import 'package:image_painter/image_painter.dart';
class DrawingScreen extends StatefulWidget {
@override
_DrawingScreenState createState() => _DrawingScreenState();
}
class _DrawingScreenState extends State<DrawingScreen> {
final _imageKey = GlobalKey<ImagePainterState>();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.only(top: 50.0),
child: Center(
child: Column(
children: [
SizedBox(
height: 600,
child: ImagePainter.network(
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ-MhSib_BLGD1SYgEQpXUmmQy0TfyJjEbfDA",
key: _imageKey,
colors: const [Colors.red, Colors.blue],
scalable: true,
initialPaintMode: PaintMode.freeStyle,
),
),
Container(
margin: const EdgeInsets.only(top: 20.0),
child: ElevatedButton(
onPressed: () {
// Save or process the user's drawing here
},
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: Colors.green,
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 12,
),
textStyle: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
child: const Text('Submit'),
),
),
],
),
),
),
);
}
}
字符串
1条答案
按热度按时间7rtdyuoh1#
流这个例子。
字符串
新增保存文件方式