wechat_assets_picker

repository·main·Indexed 23 days ago

https://github.com/fluttercandies/flutter_wechat_assets_picker

A high-performance, customizable image, video, and audio picker for Flutter providing a WeChat-style user interface. Built on top of photo_manager and extended_image, it supports single and multiple asset picking modes, custom grid layouts via AssetPickerConfig, and integration with AssetEntity and AssetPathEntity for media management across Android, iOS, and macOS.

Tokens
12.5K
Snippets
22
Records
70
Agent score
79%

What's inside wechat_assets_picker

  1. Overview of Flutter WeChat Assets Picker

    main

    Flutter WeChat Assets Picker is a Flutter plugin that provides a media picker UI modeled after the WeChat interface. It supports selecting images, videos, and audio files.

    Key Features:

    • WeChat Style UI: Replicates the WeChat asset selection experience.
    • Media Support: Supports images (including HEIF/HEIC), videos, and audio.
    • Accessibility: Full support for TalkBack and VoiceOver.
    • Customization: Highly customizable via ThemeData, proxy-based reloading, and custom widget/text/filtering rules.
    • Platform Support: Works on Android, iOS, and macOS.
    • Internationalization: Supports i18n and RTL (Right-to-Left) languages.

    Important Notes:

    • Camera Functionality: This plugin is for selecting existing assets. If you need to capture new photos or record videos, you must use the wechat_camera_picker plugin in conjunction with this one.
    • HEIF/HEIC Support: While the plugin can fetch and convert HEIF images, displaying them depends on Flutter's image parsing. For reliable display, use entity.file or AssetEntityImage.
    • Audio Limitations: Due to iOS and macOS system restrictions, audio access is limited to files within the application sandbox.
  2. Understand core concepts: AssetEntity and AssetPathEntity

    main

    The package is deeply integrated with the photo_manager plugin. To use this picker effectively, you must understand two fundamental concepts from photo_manager:

    1. AssetEntity: Represents an individual asset, such as a specific photo, video, or audio file.
    2. AssetPathEntity: Represents a collection of assets, such as an album or a library (e.g., 'Recent', 'Camera', or a custom album).

    For detailed API information regarding these entities, refer to the photo_manager documentation.

  3. Core Concepts: AssetEntity and AssetPathEntity

    main

    The flutter_wechat_assets_picker plugin is tightly coupled with the photo_manager package. To use this plugin effectively, you must understand two fundamental concepts from photo_manager:

    1. AssetEntity: Represents an individual media resource (an image, a video, or an audio file).
    2. AssetPathEntity: Represents a collection of resources, such as a specific album or a system folder (e.g., 'Recent', 'Camera Roll').

    Most behaviors and API interactions in the picker are controlled by these underlying photo_manager abstractions.

  4. How to create custom pickers

    main

    You can fully customize the picker's themes, widgets, or layouts by overriding the following exposed classes:

    • AssetPickerBuilderDelegate
    • AssetPickerViewerBuilderDelegate
    • AssetPickerProvider
    • AssetPickerViewerProvider

    To implement them, extend the class and provide your own implementation for the abstract methods using generic types <A: Asset, P: Path>.

  5. Migrate to the Builder pattern in version 5.0.0

    main

    Starting from version 5.0.0, AssetPicker and AssetPickerViewer act as builders. Most widget construction has been moved to abstract delegates: AssetPickerBuilderDelegate and AssetPickerViewerBuilderDelegate. This change allows for building custom pickers with custom types, styles, and widgets.

    Key changes for users:

    • If using AssetPickerViewer.pushToViewer, the property assets has been renamed to previewAssets.
    • If extending AssetPickerProvider or AssetPickerViewerProvider, you must now pass generic types for Asset and Path and handle entities manually.
  6. How localization works in the picker

    main

    The package reads the Locale? from your BuildContext to provide localized text. If a Locale cannot be retrieved via BuildContext, it defaults to Chinese.

    Built-in languages include:

    • Simplified Chinese (Default)
    • English
    • Hebrew
    • German
    • Russian
    • Japanese
    • Arabic
    • French
    • Vietnamese
    • Turkish

    To use a custom or fixed localization implementation, pass an AssetPickerTextDelegate through AssetPickerConfig.textDelegate.

  7. Customize Localizations

    main

    The package automatically obtains the Locale? from your BuildContext to provide localized text.

    Important: Ensure you have a valid Locale in your widget tree. If no valid locale is found, the package defaults to Chinese (简体中文).

    Supported embedded languages:

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

    To use a custom or fixed text delegate, pass it through AssetPickerConfig.textDelegate.

  8. Check Flutter version compatibility

    main

    The package guarantees compatibility only with the stable version of Flutter. It does not align with beta or master channels in real-time.

    If you encounter resolve conflict errors during flutter pub get, use dependency_overrides in your pubspec.yaml to resolve them.

    Compatibility Matrix (Partial):

    • v10.0.0+: Requires Flutter 3.27+
    • v9.5.0+: Requires Flutter 3.22+
    • v8.9.0+: Requires Flutter 3.16+
    • v8.7.0+: Requires Flutter 3.13+
    • v8.5.0+: Requires Flutter 3.10+
  9. Configure macOS for wechat_assets_picker

    main

    To use the package on macOS, follow these steps:

    1. Update Platform Version: Ensure your macOS platform version is at least 10.15. Modify your macos/Podfile:

      platform :osx, '10.15'
    2. Set Deployment Target: Use Xcode to open macos/Runner.xcworkspace and set the minimum deployment target to 10.15.

    3. Add Permissions: Follow the iOS instructions to add the NSPhotoLibraryUsageDescription key to your Info.plist file.

    platform :osx, '10.15'
  10. Update custom AssetPickerBuilderDelegate in version 7.0.0

    main

    If you extend AssetPickerBuilderDelegate, note the following breaking changes in version 7.0.0:

    • Provider Management: The abstract delegate no longer requires a provider argument. Custom delegates are now responsible for maintaining their own providers.
    • Lifecycle: ChangeNotifierProvider is no longer held inside the pickAssets method; custom delegates must provide the notifier themselves.
    • Required Methods: Custom delegates must implement isSingleAssetMode, selectAsset, assetGridItemSemanticsBuilder, and build.
    • Disposal: The dispose method must call super.dispose() when extending.
    • Renamed Properties: gridThumbSize, pathThumbSize, and previewThumbSize have been renamed to gridThumbnailSize, pathThumbnailSize, and previewThumbnailSize respectively, and their types have changed.