image_downloader 0.9.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 90

image_downloader

Flutter plugin that downloads images on the Internet and saves them on device.
This will keep Exif(DateTimeOriginal) and GPS(Latitude, Longitude).

For Android, image is saved in Environment.DIRECTORY_DOWNLOADS.
For ios, image is saved in Photo Library.

Getting Started

ios

Add the following keys to your Info.plist file, located in <project root>/ios/Runner/Info.plist:

  • NSPhotoLibraryUsageDescription - Specifies the reason for your app to access the user’s photo library. This is called Privacy - Photo Library Usage Description in the visual editor.
  • NSPhotoLibraryAddUsageDescription - Specifies the reason for your app to get write-only access to the user’s photo library. This is called Privacy - Photo Library Additions Usage Description in the visual editor.

Android

Add this permission in AndroidManifest.xml.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Example

bool isSuccess;
try {
  isSuccess = await ImageDownloader.downloadImage("https://flutter.io/images/flutter-mark-square-100.png");
} on PlatformException catch (_) {
  isSuccess = false;
}

True if saving succeeded.
False if not been granted permission.
Otherwise it is a PlatformException.

0.9.1

  • Fix warnings of Dart Analysis.
  • Describe some documents.
  • Update ImageDownloder to private constructor.

0.9.0

  • initial public release.

example/README.md

image_downloader_example

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_downloader/image_downloader.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _isSuccess = false;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Text('Running on: $_isSuccess\n'),
              RaisedButton(
                onPressed: () {
                  _downloadImage();
                },
                child: Text("save image."),
              ),
            ],
          ),
        ),
      ),
    );
  }

  Future<void> _downloadImage() async {
    bool isSuccess;
    try {
      isSuccess = await ImageDownloader.downloadImage("https://flutter.io/images/flutter-mark-square-100.png");
    } on PlatformException catch (_) {
      isSuccess = false;
    }

    if (!mounted) return;

    setState(() {
      _isSuccess = isSuccess;
    });
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  image_downloader: ^0.9.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:image_downloader/image_downloader.dart';
  
Version Uploaded Documentation Archive
0.9.1 Nov 27, 2018 Go to the documentation of image_downloader 0.9.1 Download image_downloader 0.9.1 archive
0.9.0 Nov 6, 2018 Go to the documentation of image_downloader 0.9.0 Download image_downloader 0.9.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
80
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
90
Learn more about scoring.

We analyzed this package on Jan 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.10
  • Flutter: 1.1.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/image_downloader.dart.

Run flutter format to format lib/image_downloader.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8