downloadImage static method

Future<String?> downloadImage(
  1. String url, {
  2. String? outputMimeType,
  3. Map<String, String>? headers,
  4. AndroidDestinationType? destination,
})

Save the image of the specified url on each devices.

ios will be saved in Photo Library. Android will be saved in the specified AndroidDestinationType. (default: setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, `yyyy-MM-dd.HH.mm.sss.

Returns imageId of the saved image if saving succeeded. Returns null if not been granted permission. Otherwise it is a PlatformException.

imageId is in case of Adroid, MediaStore.Images.Media._ID, in case of ios, PHObjectPlaceholder#localIdentifier.

Implementation

static Future<String?> downloadImage(
  String url, {
  String? outputMimeType,
  Map<String, String>? headers,
  AndroidDestinationType? destination,
}) async {
  return _channel.invokeMethod<String>('downloadImage', {
    'url': url,
    'mimeType': outputMimeType,
    'headers': headers,
    'inPublicDir': destination?._inPublicDir,
    'directory': destination?._directory,
    'subDirectory': destination?._subDirectory,
  });
}