custom_multi_image_picker 2.1.24

custom_multi_image_picker #

build pub package

Flutter plugin that allows you to display multi image picker on iOS and Android.

iOS #

Screenshot iOS 1 Screenshot iOS 2 Screenshot iOS 3

For the iOS picker the plugin uses BSImagePicker

Android #

Screenshot Anroid 1 Screenshot Anroid 2 Screenshot Anroid 3

For the Android picker the plugin uses Matisse

Usage #

First you need to add the plugin to your project.

iOS #

You need to add those strings to your Info.plist file in order the plugin to work:

<key>NSPhotoLibraryUsageDescription</key>
<string>Example usage description</string>
<key>NSCameraUsageDescription</key>
<string>Example usage description</string>

Android #

You need to request those permissions in AndroidManifest.xml in order the plugin to work:

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

For example code usage, please see here

Theming and localization #

You can customize different parts of the gallery picker. For reference see below the available options for the different platforms:

Customization on Android

Customization on iOS

API #

MultiImagePicker

Asset

TODO #

  • [x] Add support for more plugin specific options for iOS and Android, that allows more customization
  • [x] Improve docs
  • [ ] Allow choosing videos

License #

MIT © Radoslav Vitanov

Change Log #

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Changed (v2.1.23) #

2018-08-31 #

Added #

  • Improved the docs

Changed (v2.1.22) #

2018-08-28 #

Added #

  • Add originalWidth, originalHeight, isPortrait and isLandscape getters for the Asset class

Changed (v2.1.21) #

2018-08-24 #

Added #

  • Add release(), releaseOriginal() and releaseThumb() methods to help clean up the image data when it is no longer needed

Changed (v2.1.02) #

2018-08-20 #

Fix #

  • Fix null pointer exception on Android when finishing from another activity (thanks to xia-weiyang)

Changed (v2.1.01) #

2018-08-16 #

Change #

  • Add getters to Asset class

Changed (v2.1.00) #

2018-08-16 #

BREAKING CHANGE #

  • Asset's requestThumbnail and requestOriginal methods now will return Future

Changed (v2.0.04) #

2018-08-16 #

Fixed #

  • Correctly crop the thumb on iOS

Changed (v2.0.03) #

2018-08-16 #

Added #

  • Allow network access to download images present only in iCloud

Changed (v2.0.02) #

2018-08-16 #

Fixed #

  • Improve thumbs quality on iOS to always deliver best of it

Changed (v2.0.01) #

2018-08-16 #

Fixed #

  • Fix picking original image on Android was not triggering properly the callback

Changed (v2.0.0) #

2018-08-15 #

BREAKING CHANGE #

  • The plugin have been redesigned to be more responsive and flexible.
  • pickImages method will no longer return List
  • You can then request asset thumbnails or the original image, which will load asyncrhoniously without blocking the main UI thred. For more info see the examples directory.

Added #

  • Asset class, with methods requestThumbnail(int width, int height, callback) and requestOriginal(callback)

Changed (v1.0.53) #

2018-08-13 #

Fixed #

  • Fix crash on iOS when picking a lot of images.

Changed (v1.0.52) #

2018-08-12 #

Fixed #

  • Picking images on iOS now will properly handle PHAssets

Changed (v1.0.51) #

2018-08-07 #

Changed #

  • Fix a crash on Android caused by closing and reopening the gallery

Changed (v1.0.5) #

2018-08-07 #

Add #

  • Support iOS and Android customizations

Changed (v1.0.4) #

2018-08-06 #

Changed #

  • iOS: Add missing super.init() call in the class constructor

Changed (v1.0.3) #

2018-08-05 #

Changed #

  • Changed sdk: ">=2.0.0-dev.28.0 <3.0.0"

Changed (v1.0.2) #

2018-08-05 #

Added #

  • Add Support for Dart 2 in pubspec.yaml file

Changed (v1.0.1) #

2018-08-05 #

Added #

  • Initial release with basic support for iOS and Android

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:custom_multi_image_picker/asset.dart';
import 'package:custom_multi_image_picker/custom_multi_image_picker.dart';
import 'asset_view.dart';

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

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

class _MyAppState extends State<MyApp> {
  List<Asset> images = List<Asset>();
  String _error;

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

  Widget buildGridView() {
    return GridView.count(
      crossAxisCount: 3,
      children: List.generate(images.length, (index) {
        return AssetView(index, images[index]);
      }),
    );
  }

  Future<void> loadAssets() async {
    setState(() {
      images = List<Asset>();
    });

    List resultList;
    String error;

    try {
      resultList = await MultiImagePicker.pickImages(
        maxImages: 300,
      );

    } on PlatformException catch (e) {
      error = e.message;
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      images = resultList;
      // print(images[0].getPath) ; 
      if (error == null) _error = 'No Error Dectected';
    });
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: <Widget>[
            Center(child: Text('Error: $_error')),
            RaisedButton(
              child: Text("Pick images"),
              onPressed: loadAssets,
            ),
            Expanded(
              child: buildGridView(),
            )
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  custom_multi_image_picker: ^2.1.24

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:custom_multi_image_picker/custom_multi_image_picker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
75
Health:
Code health derived from static analysis. [more]
95
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
84
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/asset.dart. (-4.89 points)

Analysis of lib/asset.dart reported 10 hints, including:

line 126 col 5: 'BinaryMessages' is deprecated and shouldn't be used.

line 126 col 20: 'setMessageHandler' is deprecated and shouldn't be used.

line 126 col 48: This function has a return type of 'Future

line 129 col 7: 'BinaryMessages' is deprecated and shouldn't be used.

line 129 col 22: 'setMessageHandler' is deprecated and shouldn't be used.

Format lib/custom_multi_image_picker.dart.

Run flutter format to format lib/custom_multi_image_picker.dart.

Format lib/picker.dart.

Run flutter format to format lib/picker.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (meta).

Dependencies

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