Solution unclear
harshkumarkhatri opened this issue · comments
Harsh Kumar Khatri commented
Hey. I have gone through your code and I found it unclear.
Can you please update it such that others can have a better reference to it?
Mat Schlenker commented
Using the new requirements, I came out with this code - maybe that's more clear for you:
final recorder = PictureRecorder();
final canvas = Canvas(
recorder,
Rect.fromPoints(const Offset(0.0, 0.0), const Offset(200.0, 200.0)));
final stroke = Paint()
..color = Colors.grey
..style = PaintingStyle.stroke;
canvas.drawRect(
const Rect.fromLTWH(0.0, 0.0, 200.0, 200.0), stroke);
final paint = Paint()
..color = Colors.purple
..style = PaintingStyle.fill;
canvas.drawCircle(
const Offset(
200.0,
200.0,
),
20.0,
paint);
final picture = recorder.endRecording();
final img = await picture.toImage(200, 200);
final pngBytes = await img.toByteData(format: ImageByteFormat.png);
Harsh Kumar Khatri commented
Now it's much more clear. Thanks for the update.