local_image_provider 0.6.0

  • Readme
  • Changelog
  • Example
  • Installing
  • new70

Local Image Provider Plugin #

A library for searching and retrieving the metadata and contents of the images and albums on a mobile device.

This plugin contains a set of classes that make it easy to discover the metadata of the images and albums on the mobile device. It supports both Android and iOS. The content of images can be retrieved in a format compatible with the ImageProvider. Note that this plugin has no UI components, it provides information about local photos that can be used to develop other applications.

Recent Updates #

The 0.6.0 version changed some methods from 'get' to 'find' to better match the functionality.

The 0.5.2 version of this plugin added permission handling. Previous versions used an external permission plugin to handle the required platform permissions but those dependencies were causing problems so they've been removed. The initialize method now handles permission checking and is required as the first call to the plugin.

Note: This plugin is under development and will be extended over the coming weeks. It is not yet fully tested on multiple platforms. If you have any compatibility results you'd like to share please post them as issues.

Using #

To retrieve the list of latest local images just import the package and call the plugin, like so:

import 'package:local_image_provider/local_image_provider.dart' as lip;

    lip.LocalImageProvider imageProvider = lip.LocalImageProvider();
    bool hasPermission = await imageProvider.initialize();
    if ( hasPermission) {
        List<lip.LocalImage> images = await imageProvider.findLatest(10);
        images.forEach((image) => print( image.id));
    else {
        print("The user has denied access to images on their device.");

Get an ImageProvider for an image like so:

import 'package:local_image_provider/local_image_provider.dart' as lip;
import 'package:flutter/painting.dart';
// ...

    lip.LocalImageProvider imageProvider = lip.LocalImageProvider();
    bool hasPermission = await imageProvider.initialize();
    if ( hasPermission) {
        List<lip.LocalImage> images = await imageProvider.findLatest(1);
        if ( !images.isEmpty ) {
            lip.LocalImage image = images.first;
            MemoryImage mImg = MemoryImage( await image.getImageBytes( 300, 300 ));
        else {
            print("No images found on the device.");
    else {
        print("The user has denied access to images on their device.");

Permissions #

Applications using this plugin require the following user permissions.

iOS #

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

  • NSPhotoLibraryUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor. This permission is required for the app to read the image and album information.

Android #

Add the storage permission to your AndroidManifest.xml file, located in <project root>/android/app/src/main/AndroidManifest.xml:

  • android.permission.READ_EXTERNAL_STORAGE - this allows the app to query and read the image and album information.

Changelog #

0.6.0 #

Breaking #

  • renamed getLatest -> findLatest
  • renamed getAlbums -> findAlbums

New #

  • findImagesInAlbum to list all the images contained in a particular album

0.5.2 #

Breaking #

  • Added initialize method, now required before using the plugin
  • Methods are no longer static, you must now create an instance and use that

Updates #

  • Added permission checking to both iOS and Android

0.5.1 #

  • Fixes issues pointed out by pub_dev analysis
  • updated description in pubspec
  • updated json_annotation dependency to 3.0
  • ran format on dart files

0.5.0 #

  • Initial release with limited functionality, supports only:
    • getting album descriptions
    • getting latest image descriptions
    • getting bytes for image.
  • Android and iOS 10+ support


Local Image Provider Example #

Demonstrates how to use the local_image_provider plugin. This example requires that the plugin has been installed and that the app has had the required permission declarations added. The example lists the available albums and images on the device.

Source #

import 'package:local_image_provider/local_album.dart';
import 'package:local_image_provider/local_image.dart';
import 'package:local_image_provider/local_image_provider.dart';

void main() async {
  print('In main.');
  LocalImageProvider imageProvider = LocalImageProvider();
  bool hasPermission = await imageProvider.initialize();
  if ( hasPermission ) {
    List<LocalAlbum> albums =
        await imageProvider.findAlbums(LocalAlbumType.all);
    print('Got albums: ${albums.length}');
    albums.forEach((album) => print(
        'Title: ${album.title}, id: ${album.id}, coverImgId: ${album.coverImgId}'));

    List<LocalImage> images = await imageProvider.findLatest(10);
    print('Got images: ${images.length}');
    images.forEach((image) => print(
        'id: ${image.id}, height: ${image.pixelHeight}, width: ${image.pixelWidth}'));
  else {
        print("The user has denied access to images on their device.");

Use this package as a library

1. Depend on it

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

  local_image_provider: ^0.6.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:local_image_provider/local_image_provider.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/local_image_provider.dart.

Run flutter format to format lib/local_image_provider.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
json_annotation ^3.0.0 3.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
build_runner ^1.0.0
json_serializable ^3.0.0