GithubHelp home page GithubHelp logo

lizubing1992 / flutter_photo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from caijinglong/flutter_photo

0.0 1.0 1.0 233 KB

Pick image/video from album by flutter. Support ios and android. UI by flutter, no native.

License: Apache License 2.0

Java 0.38% Dart 94.47% Ruby 4.36% Objective-C 0.79%

flutter_photo's Introduction

photo

pub package pub package GitHub GitHub stars

image picker, multi picker

support ios icloud

support video

use flutter as ui

if you want to build custom ui, you just need api to make custom ui. to use photo_manager or fork the library to custom ui.

Screenshot

image

install

latest version : pub package pub package

dependencies:
  photo: $latest_version

Import

import 'package:photo/photo.dart';
import 'package:photo_manager/photo_manager.dart';

Usage

Simple use

void pickAssets() async {
    List<AssetEntity> assetList = await PhotoPicker.pickAsset(context: context);
    /// Use assetList to do something.
}

More option

The context is required, other params is optional.

void pickAsset() async {
    List<AssetEntity> imgList = await PhotoPicker.pickAsset(
      context: context,
      // BuildContext requied

      /// The following are optional parameters.
      themeColor: Colors.green,
      // the title color and bottom color
      padding: 1.0,
      // item padding
      dividerColor: Colors.grey,
      // divider color
      disableColor: Colors.grey.shade300,
      // the check box disable color
      itemRadio: 0.88,
      // the content item radio
      maxSelected: 8,
      // max picker image count
      provider: I18nProvider.chinese,
      // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
      rowCount: 5,
      // item row count
      textColor: Colors.white,
      // text color
      thumbSize: 150,
      // preview thumb size , default is 64
      sortDelegate: SortDelegate.common,
      // default is common ,or you make custom delegate to sort your gallery
      checkBoxBuilderDelegate: DefaultCheckBoxBuilderDelegate(
        activeColor: Colors.white,
        unselectedColor: Colors.white,
        checkColor: Colors.blue,
      ), // default is DefaultCheckBoxBuilderDelegate ,or you make custom delegate to create checkbox

      loadingDelegate:
          this, // if you want to build custom loading widget,extends LoadingDelegate [see example/lib/main.dart]

      badgeDelegate: const DefaultBadgeDelegate(), /// or custom class extends [BadgeDelegate]

      pickType: type, // all/image/video

      List<AssetPathEntity> photoPathList, /// when [photoPathList] is not null , [pickType] invalid .
    );

About photoPathList params

You can use [photo_manager] package to get List<AssetPathEntity> and handle or cache.

This parameter is then passed into the pickAsset method, where the incoming photoList is rendered instead of the data in the album.

Whole example

You can see github main.dart

About android

Migrate to androidX

See the gitbook

Glide

Android native use glide to create image thumb bytes, version is 4.8.0.

If your other android library use the library, and version is not same, then you need edit your android project's build.gradle.

rootProject.allprojects {

    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.github.bumptech.glide'
                        && details.requested.name.contains('glide')) {
                    details.useVersion "4.8.0"
                }
            }
        }
    }

}

if you use the proguard

see the github

About ios

Because the album is a privacy privilege, you need user permission to access it. You must to modify the Info.plist file in Runner project.

like next

<key>NSPhotoLibraryUsageDescription</key>
<string>App need your agree, can visit your album</string>

xcode like image in xcode

Build error

if you build error like include of non-modular header inside framework module, see #10 or so

Thanks

Part of the Android code comes from debuggerx01.

Donate

If my code helps you, and you're willing to buy me a cup of coffee.

you can use paypal

or scan my alipay

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.