encodeImageFile function
Encode the image
to a file at the given path
. The format of the image
file is determined from the extension of the file. If the image was
successfully written to the file, true will be returned, otherwise false.
For platforms that do not support dart:io, false will be returned.
Implementation
Future<bool> encodeImageFile(String path, Image image) async {
if (!supportsFileAccess()) {
return false;
}
final encoder = findEncoderForNamedImage(path);
if (encoder == null) {
return false;
}
final bytes = encoder.encode(image);
return writeFile(path, bytes);
}