Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save a Flutter canvas as a bitmap image?

Tags:

flutter

I have a Flutter canvas , and I'd like to save that canvas as a bitmap image (e.g. PNG, but any common bitmap format will do). What's the best way to get the bits out of a canvas, converted to a bitmap image format?

Thanks very much!

like image 939
Seth Ladd Avatar asked Aug 14 '17 17:08

Seth Ladd


1 Answers

  1. Create a PictureRecorder.
  2. Create a Canvas with your PictureRecorder and draw stuff.
  3. Call endRecording() on the PictureRecorder to get a Picture.
  4. Call toImage() on the Picture.
  5. Call toByteData() on the Image. Oops, this isn't implemented yet. I filed an issue.
like image 145
Collin Jackson Avatar answered Sep 28 '22 12:09

Collin Jackson