I have an image which I got from a Canvas PictureRecorder
. Now I want to upload it to Firebase storage. My issue is converting it to a png file to upload. I don't know much about converting images, so not sure how to manipulate it in a way to upload as a png file.
final picture = recorder.endRecording();
final img = picture.toImage(640, 360);
final pngBytes = await img.toByteData();
final Directory systemTempDir = Directory.systemTemp;
final File file = await new File('${systemTempDir.path}/foo.png').create();
file.write?????(pngBytes); <-- Not sure how to write the file here
final StorageReference ref =
storage.ref().child('images').child('image.png');
final StorageUploadTask uploadTask =
ref.putFile(file);