image_downloader_saver

A no-dependency Flutter plugin for downloading and saving images to the Gallery or App Files (Downloads) directory, with smart duplicate detection and clear HTTP-style status codes. Works fully on Android and iOS.


Features

  • Save image to Gallery or Files (Downloads)
  • Detect duplicates before saving
  • Return clear HTTP-style status codes
  • Works offline and online
  • Native Android & iOS implementation
  • No extra dependencies for saving
  • Full example app included

Status Codes

Code Meaning Description
200 OK Success
201 Created Image downloaded and saved
208 Already Exists Duplicate detected
400 Bad Request Invalid URL or input
401 Permission Denied User denied access
404 Download Failed Image not found or connection error
500 Internal Error Native or unexpected exception

API Reference

ImageSaver.saveImage

Downloads an image from a URL and saves it either to the Gallery or Files (Downloads) directory.

Parameters

Name Type Description
url String The URL of the image to download
saveTo SaveLocation (optional) SaveLocation.gallery or SaveLocation.files

Returns

A SaveResult object with:

  • code → Numeric HTTP-style status code
  • message → Human-readable message
  • isSuccess → Boolean (true if code is 200, 201, or 208)

SaveResult

Field Type Description
code int Numeric HTTP-style status code
message String Human-readable message
isSuccess bool True if code is 200, 201, or 208

SaveLocation

Value Description
gallery Save image to device Gallery
files Save image to Downloads directory

Usage Example

import 'package:image_downloader_saver/image_downloader_saver.dart';

void main() async {
  final result = await ImageSaver.saveImage(
    'https://picsum.photos/400',
    saveTo: SaveLocation.gallery,
  );

  print('${result.code} → ${result.message}');
}

Permissions

Android

Add the following permissions to your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />

iOS

Add these keys to your Info.plist:

<key>NSPhotoLibraryAddUsageDescription</key>
<string>We need permission to save images to your gallery.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to check existing images.</string>

Example App

An example Flutter app is included in the example/ directory.

Run the example:

cd example
flutter run

Troubleshooting

Problem Solution
Image not visible in Gallery Reopen Gallery; indexing may take a few seconds.
Permission denied Allow Photos or Storage permission in device settings.
Duplicate saved images The plugin automatically prevents duplicates.
Download failed Check the image URL and network connection.

Supported Platforms

Platform Supported
Android ✅ Yes
iOS ✅ Yes
Web ❌ No
macOS ⏳ Planned
Windows ⏳ Planned

Maintainer

Author: Mohamed Elshenawy
Email: [email protected]
Repository: GitHub - melshenawyarabapps/image_downloader_saver
License: MIT