搜索插件、代码仓与 APP 分类

drishya_picker 封面
插件详情v2.0.0

drishya_picker

一个受Messenger 相机和相册启发的资源选择器。

近 30 天下载
53
喜欢数
92
Pub 分数
60

安装插件

flutter pub add drishya_picker

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Drishya Picker 是一个 Flutter 包,提供了一个受消息应用中的相机和相册界面启发的资源选择器。它能够以简洁直观的界面让用户选择图片和视频,实现无缝的媒体集成。该包基于 Flutter 构建,支持在相机拍摄和相册浏览之间流畅切换,非常适合聊天或社交媒体应用。该包轻量且易于集成,无需大量自定义即可提供现代化的用户体验。目前未指定平台限制,表明具有广泛的兼容性。

适合场景

  • 支持媒体共享的聊天应用
  • 社交媒体帖子创建
  • 用户个人资料照片和视频上传
  • 内容创作工具
  • 富媒体表单提交

主要特点

  • 相机和相册集成
  • Messenger 风格的用户界面设计
  • 与 Flutter 的简单集成
  • 轻量且高效
  • 直观的媒体选择流程

适合对象

  • 开发即时通讯应用的开发者
  • 需要快速上传媒体的应用
  • 面向用户界面的多媒体选择器
  • Flutter 初学者寻找现成的组件
  • 希望获得原生类似选择器体验的项目

使用建议

  • 未列出明确的平台支持
  • 可用文档有限
  • 可能需要额外的权限才能访问摄像头
  • 依赖外部依赖项以实现完整功能
  • 尚未在生产环境中广泛采用

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Drishya Picker

Platform Pub Package likes Forks


A flutter package which is clone of facebook messenger gallery picker and camera, combined as single component. Gallery view and Camera view can also be use as Flutter widget. Under the hood drishya picker used Photo Manager and Camera.


Table of contents


Installing

1. Add dependency

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

dependencies:
  drishya_picker: ^latest_version
2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get
3. Import it

Now in your Dart code, you can use:

import 'package:drishya_picker/drishya_picker.dart';

Platform Setup

For more details (if needed) you can go through Photo Manager and Camera readme section as well.

Android

Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.

minSdkVersion 21

Required permissions: INTERNET, READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE, ACCESS_MEDIA_LOCATION. If you don't need the ACCESS_MEDIA_LOCATION permission, see Disable ACCESS_MEDIA_LOCATION permission.

glide

Android native use glide to create image thumb bytes, version is 4.11.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.11.0'
                }
            }
        }
    }
}

And, if you want to use ProGuard, you can see the ProGuard of Glide.

Remove Media Location permission

Android contains ACCESS_MEDIA_LOCATION permission by default.

This permission is introduced in Android Q. If your app doesn't need this permission, you need to add the following node to the Android manifest in your app.

<uses-permission
  android:name="android.permission.ACCESS_MEDIA_LOCATION"
  tools:node="remove"
  />

If you found some warning logs with Glide appearing, then the main project needs an implementation of AppGlideModule. See Generated API.

IOS

Add following content to info.plist.

<key>NSPhotoLibraryUsageDescription</key>
<string>Replace with your permission description..</string>
<key>NSCameraUsageDescription</key>
<string>Replace with your permission description..</string>
<key>NSMicrophoneUsageDescription</key>
<string>Replace with your permission description..</string>

Gallery

  1. Use SlidableGallery to make gallery view slidable otherwise ignore it.
class PickerDemo extends StatelessWidget {
 late final GalleryController controller;
 
 ...

 @override
 Widget build(BuildContext context) {
   return SlidableGallery(
     controller: controller,
     child: Scaffold(
       body: ...
     ),
   );
 }
}
  1. GallerySetting can be used for extra setting while picking media.
  • Using pick() function on controller to pick media.
class PickerDemo extends StatelessWidget {
  late final GalleryController controller;

  @override
  void initState() {
    super.initState();
    controller = GalleryController();
  }

    
  final _gallerySetting = GallerySetting(
      enableCamera: true,
      maximumCount: 10,
      requestType: RequestType.all,
      editorSetting: EditorSetting(colors: _colors, stickers: _stickers1),
      cameraSetting: const CameraSetting(videoDuration: Duration(seconds: 15)),
      cameraTextEditorSetting: EditorSetting(
        backgrounds: _defaultBackgrounds,
        colors: _colors.take(4).toList(),
        stickers: _stickers2,
      ),
      cameraPhotoEditorSetting: EditorSetting(
        colors: _colors.skip(4).toList(),
        stickers: _stickers3,
      ),
    );

  ...

  onPressed : () async {
    final entities = await controller.pick(context,setting:setting);
  }

  ...
}
  1. Using GalleryViewField similarly to flutter TextField to pick media. (Recommended approach, as creating and disposing of the controller has been already cared-of )
  • onChanged – triggered whenever a user select/unselect media

  • onSubmitted – triggered when a user is done with the selection

GalleryViewField(
  selectedEntities: [],
  onChanged: (entity, removed) {
     ...
  },
  onSubmitted: (list) {
     ...
  }
  child: const Icon(Icons.camera),
),
  1. You can also use GalleryView as a Widget.

  2. Browse the example app for more in-depth implementation and customization.


Camera

  1. Using pick() function on CameraView to pick media.
  ...
  onPressed : () async {
    final entity = await CameraView.pick();
  }
  ...
  1. Using CameraViewField similarly as flutter TextField to pick media.
  • onCapture – triggered when photo/video capture completed
GalleryViewField(
  onCapture: (entity) {
     ...
  },
  child: const Icon(Icons.camera),
),
  1. You can also use CameraView as a Widget.

Bugs or Requests

If you encounter any problems feel free to open an issue. If you feel the library is missing a feature, please raise a ticket on GitHub and I'll look into it. Pull request are also welcome.


Maintainers

所属分类

依赖

依赖清单 6 项

源码仓库

使用此插件的项目

暂无相关数据。