Project Icon

flutter_wechat_assets_picker

微信风格的Flutter多媒体资源选择器

flutter_wechat_assets_picker是一个模仿微信界面的Flutter多媒体资源选择器。该插件支持选择图片、视频和音频,提供单选和多选模式。它具有完整的无障碍支持、可自定义主题、国际化等特性,同时允许开发者自定义资源排序和过滤选项。该选择器在保持微信UI风格的基础上,还提供了更多自定义功能,可满足多样化的媒体选择需求。

Flutter WeChat Assets Picker

pub package pub package CodeFactor

Build status GitHub license GitHub stars GitHub forks

Awesome Flutter Flutter Candies QQ群

Language: English | 中文

An image picker (also with videos and audios) for Flutter projects based on the WeChat's UI.

Current WeChat version that UI based on: 8.3.x UI designs will be updated following the WeChat update in anytime.

To take a photo or a video for assets, please check the detailed usage in the example, and head over to [wechat_camera_picker][wechat_camera_picker pub]. The package is a standalone extension that can to be used with combination.

See the [Migration Guide][] to learn how to migrate between breaking changes.

Versions compatibility

The package only guarantees to be working on the stable version of Flutter. We won't update it in real-time to align with other channels of Flutter.

3.03.33.73.103.133.16
8.9.0+
8.7.0+
8.5.0+
8.4.0+
8.0.0+
7.3.0+

If you got a resolve conflict error when running flutter pub get, please use dependency_overrides to fix it.

Package credits

The package is built from these wonderful packages.

NameFeatures
[photo_manager][photo_manager pub]The basic abstractions and management for assets.
[extended_image][extended_image pub]Preview assets with expected behaviors.
[provider][provider pub]Helps to manage the interaction state of the picker.
[video_player][video_player pub]Plays videos and audios correspondingly.

Their implementation should be relatively stable in the package. If you've found any issues related to them when using the picker, submit issues to our issue tracker first.

Table of content

Features ✨

  • ♿ Complete a11y support with TalkBack and VoiceOver
  • ♻️ Fully customizable with delegates override
  • 🎏 Fully customizable theme based on ThemeData
  • 💚 Completely WeChat style (even more)
  • ⚡️ Adjustable performance with different configurations
  • 📷 Image support
    • 🔬 HEIF Image type support (1)
  • 🎥 Video support
  • 🎶 Audio support (2)
  • 1️⃣ Single picking mode
  • 💱 Internationalization (i18n) support
    • ⏪ RTL language support
  • ➕ Special item builder support
  • 🗂 Custom sort path delegate support
  • 📝 Custom text delegate support
  • ⏳ Custom filter options support
  • 💻 macOS support

Notes 📝

  1. HEIF (HEIC) images are support to obtain and conversion, but the display with them are based on Flutter's image decoder. See flutter/flutter#20522. Use entity.file or AssetEntityImage for them when displays.
  2. Due to limitations on iOS and macOS, audio can only be fetched within the sandbox.

Projects using this plugin 🖼️

namepubgithub
insta_assets_pickerpub packagestar

Screenshots 📸

123
456
789
101012

READ THIS FIRST ‼️

Be aware of below notices before you started anything:

  • Due to understanding differences and the limitation of a single document, documents will not cover all the contents. If you find nothing related to your expected features and cannot understand about concepts, run the example project and check every options first. It has covered 90% of regular requests with the package.
  • The package deeply integrates with the [photo_manager][photo_manager pub] plugin, make sure you understand these two concepts as much as possible:

When you have questions about related APIs and behaviors, check [photo_manager's API docs][] for more details.

Most usages are detailed covered by the example. Please walk through the example carefully before you have any questions.

Preparing for use 🍭

Flutter

Run flutter pub add wechat_assets_picker, or add wechat_assets_picker to pubspec.yaml dependencies manually.

dependencies:
  wechat_assets_picker: ^latest_version

The latest stable version is: pub package

The latest dev version is: pub package

Then import the package in your code:

import 'package:wechat_assets_picker/wechat_assets_picker.dart';

Android

When using the package, please upgrade targetSdkVersion and compileSdkVersion to 33. Otherwise, no assets can be fetched on Android 13.

Permissions

NameRequiredDeclaredMax API LevelOthers
READ_EXTERNAL_STORAGEYESYES32
WRITE_EXTERNAL_STORAGENONO29
ACCESS_MEDIA_LOCATIONYES*NON/ARequired when reading EXIF
READ_MEDIA_IMAGESYES*YESN/ARequired when reading images
READ_MEDIA_VIDEOYES*YESN/ARequired when reading videos
READ_MEDIA_AUDIOYES*YESN/ARequired when reading audios

If you're targeting Android SDK 33+, and you don't need to load photos, videos or audios, consider declare only relevant permission in your apps, more specifically:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.your.app">
    <!--Requesting access to images and videos.-->
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
    <!--When your app has no need to access audio, remove it or comment it out.-->
    <!--<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />-->
</manifest>

iOS

  1. Platform version has to be at least 11.0. Modify ios/Podfile and update accordingly.
    platform :ios, '11.0'
    
    Remove the # heading if the line starts with it.
  2. Add the following content to Info.plist.
<key>NSPhotoLibraryUsageDescription</key>
<string>Replace with your permission description.</string>

macOS

  1. Platform version has to be at least 10.15. Modify macos/Podfile and update accordingly.
    platform :osx, '10.15'
    
    Remove the # heading if the line starts with it.
  2. Set the minimum deployment target of the macOS to 10.15. Use XCode to open macos/Runner.xcworkspace .
  3. Follow the iOS instructions and modify Info.plist accordingly.

Usage 📖

Localizations

When you're picking assets, the package will obtain the Locale? from your BuildContext, and return the corresponding text delegate of the current language. Make sure you have a valid Locale in your widget tree that can be accessed from the BuildContext. Otherwise, the default Chinese delegate will be used.

Embedded text delegates languages are:

  • 简体中文 (default)
  • English
  • העברית
  • Deutsche
  • Локализация
  • 日本語
  • مة العربية
  • Délégué
  • Tiếng Việt
  • Türkçe Yerelleştirme

If you want to use a custom/fixed text delegate, pass it through the AssetPickerConfig.textDelegate.

Simple usage

final List<AssetEntity>? result = await AssetPicker.pickAssets(context);

Use AssetPickerConfig for more picking behaviors.

final List<AssetEntity>? result = await AssetPicker.pickAssets(
  context,
  pickerConfig: const AssetPickerConfig(),
);

Fields in AssetPickerConfig:

NameTypeDescriptionDefault
selectedAssetsList<AssetEntity>?Selected assets. Prevent duplicate selection.null
maxAssetsintMaximum asset that the picker can pick.9
pageSizeint?Number of assets per page. Must be a multiple of gridCount.80
gridThumbnailSizeThumbnailSizeThumbnail size for the grid's item.ThumbnailSize.square(200)
pathThumbnailSizeThumbnailSizeThumbnail size for the path selector.ThumbnailSize.square(80)
previewThumbnailSizeThumbnailSize?Preview thumbnail size in the viewer.null
requestTypeRequestTypeRequest type for picker.RequestType.common
specialPickerTypeSpecialPickerType?Provides the option to integrate a custom picker type.null
keepScrollOffsetboolWhether the picker should save the scroll offset between pushes and pops.null
sortPathDelegateSortPathDelegate<AssetPathEntity>?Path entities sort delegate for the picker, sort paths as you want.CommonSortPathDelegate
sortPathsByModifiedDateboolWhether to allow sort delegates to sort paths with FilterOptionGroup.containsPathModified.false
filterOptionsPMFilter?Allow users to customize assets filter options.null
gridCountintGrid count in picker.4
themeColorColor?Main theme color for the picker.Color(0xff00bc56)
pickerThemeThemeData?Theme data provider for the picker and the viewer.null
textDelegateAssetPickerTextDelegate?
项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

白日梦AI

白日梦AI提供专注于AI视频生成的多样化功能,包括文生视频、动态画面和形象生成等,帮助用户快速上手,创造专业级内容。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

讯飞绘镜

讯飞绘镜是一个支持从创意到完整视频创作的智能平台,用户可以快速生成视频素材并创作独特的音乐视频和故事。平台提供多样化的主题和精选作品,帮助用户探索创意灵感。

Project Cover

讯飞文书

讯飞文书依托讯飞星火大模型,为文书写作者提供从素材筹备到稿件撰写及审稿的全程支持。通过录音智记和以稿写稿等功能,满足事务性工作的高频需求,帮助撰稿人节省精力,提高效率,优化工作与生活。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

AIWritePaper论文写作

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号