photo_manager 0.1.4

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

photo_manager

pub package Hex.pm

A flutter api for photo, you can get image/video from ios or android

一个提供相册 api 的插件, android ios 可用,没有 ui,以便于自定义自己的界面, 你可以通过提供的 api 来制作图片相关的 ui 或插件

or use photo library , a multi image picker .All UI comes from flutter.

api changed

in 0.1.0 API incompatibility

because support video, so rename api from ImageXXXX to AssetXXXX

so 0.1.X and 0.0.X incompatibility

install

dependencies:
  photo_manager: ^0.1.3

import

import 'package:photo_manager/photo_manager.dart';

use

see the example/lib/main.dart

or see next

example

  1. you must requestPermission
var result = await PhotoManager.requestPermission();
if(result == true){
    // success
}else{
    // fail
}
  1. you get all of asset list(gallery)
List<AssetPathEntity> list = await PhotoManager.getAssetPathList();
  1. get asset list from imagePath
List<AssetEntity> imageList = await data.assetList;
  1. use the AssetEntity
AssetEntity entity = imageList[0];

File file = await entity.file; // image file

List<int> fileData = await entity.fullData; // image/video file bytes

Uint8List thumbBytes = await entity.thumbData; // thumb data ,you can use Image.memory(thumbBytes); size is 64px*64px;

Uint8List thumbDataWithSize = await entity.thumbDataWithSize(width,height); //Just like thumbnails, you can specify your own size. unit is px;

AssetType type = entity.type; // the type of asset enum of other,image,video

CHANGELOG

0.1.4 fix bug

update all path hasVideo property

0.1.3 add params

add a params to help user disable get video

0.1.2 fix bug

ios get video file is async

0.1.1 fix ios video

fix 'ios video full file is a jpg' problem

0.1.0 support video

support video in android. and will change api from ImageXXXX to AssetXXXX

0.0.3 fix bug

update for the issue #1 (NPE when request other permission on android)

0.0.2 update readme

0.0.1

first version

api for photo

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:photo_manager/photo_manager.dart';
import 'photos.dart';

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

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

class _MyAppState extends State<MyApp> {
  var pathList = <AssetPathEntity>[];

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
          actions: <Widget>[
            IconButton(
              icon: Icon(Icons.settings_applications),
              onPressed: _openSetting,
            ),
          ],
        ),
        body: new ListView.builder(
          itemBuilder: _buildItem,
          itemCount: pathList.length,
        ),
        floatingActionButton: FloatingActionButton(
          child: Icon(Icons.refresh),
          onPressed: () async {
            var result = await PhotoManager.requestPermission();
            if (!(result == true)) {
              print("未授予权限");
              return;
            }

            print("wait scan");
            List<AssetPathEntity> list = await PhotoManager.getAssetPathList(hasVideo: false);

            // print("list = $list");
            pathList.clear();
            pathList.addAll(list);
            setState(() {});

            // var r = await ImagePicker.pickImages(source: ImageSource.gallery, numberOfItems: 10);
            // print(r);
          },
        ),
      ),
    );
  }

  Widget _buildItem(BuildContext context, int index) {
    var data = pathList[index];
    return GestureDetector(
      child: ListTile(
        title: Text(data.name),
      ),
      onTap: () async {
        var list = await data.assetList;
        print("开启的相册为:${data.name} , 数量为 : ${list.length}");
        var page = PhotoPage(
          pathEntity: data,
          photos: list,
        );
        Navigator.of(context).push(MaterialPageRoute(builder: (ctx) => page));
      },
    );
  }

  void _openSetting() {
    PhotoManager.openSetting();
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  photo_manager: ^0.1.4

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:photo_manager/photo_manager.dart';
  
Version Uploaded Documentation Archive
0.1.4 Oct 17, 2018 Go to the documentation of photo_manager 0.1.4 Download photo_manager 0.1.4 archive
0.1.3 Oct 12, 2018 Go to the documentation of photo_manager 0.1.3 Download photo_manager 0.1.3 archive
0.1.2 Oct 12, 2018 Go to the documentation of photo_manager 0.1.2 Download photo_manager 0.1.2 archive
0.1.1 Oct 12, 2018 Go to the documentation of photo_manager 0.1.1 Download photo_manager 0.1.1 archive
0.1.0 Oct 11, 2018 Go to the documentation of photo_manager 0.1.0 Download photo_manager 0.1.0 archive
0.0.3 Oct 9, 2018 Go to the documentation of photo_manager 0.0.3 Download photo_manager 0.0.3 archive
0.0.2 Oct 2, 2018 Go to the documentation of photo_manager 0.0.2 Download photo_manager 0.0.2 archive
0.0.1 Oct 2, 2018 Go to the documentation of photo_manager 0.0.1 Download photo_manager 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
37
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]
69
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.12.4
  • Flutter: 0.9.5

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/photo_manager.dart.

Run flutter format to format lib/photo_manager.dart.

Dependencies

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