saveImage static method

Future<bool?> saveImage(
  1. String path, {
  2. String? albumName,
  3. bool toDcim = false,
  4. Map<String, String>? headers,
})

saves image from provided temp path and optional album name in gallery

Implementation

static Future<bool?> saveImage(
  String path, {
  String? albumName,
  bool toDcim = false,
  Map<String, String>? headers,
}) async {
  File? tempFile;
  if (path.isEmpty) {
    throw ArgumentError(pleaseProvidePath);
  }
  if (!isImage(path)) {
    throw ArgumentError(fileIsNotImage);
  }
  if (!isLocalFilePath(path)) {
    tempFile = await _downloadFile(path, headers: headers);
    path = tempFile.path;
  }

  bool? result = await _channel.invokeMethod(
    methodSaveImage,
    <String, dynamic>{'path': path, 'albumName': albumName, 'toDcim': toDcim},
  );
  if (tempFile != null) {
    tempFile.delete();
  }

  return result;
}