搜尋套件、儲存庫與 APP 分類

insta_assets_picker 封面
套件詳情v3.4.0

insta_assets_picker

一個類似於 Instagram 的影像(和影片)選擇器,支援多選、裁剪與比例。

AndroidiOS
近 30 天下載
3650
喜歡數
165
Pub 分數
150

安裝套件

flutter pub add insta_assets_picker

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,提供類似 Instagram 的圖片與影片選擇器,支援多選、裁剪與自訂比例。它為從裝置相簿中選擇媒體提供乾淨直覺的介面,非常適合需要豐富媒體上傳功能的應用程式。此選擇器針對 Android 與 iOS 平台進行優化,確保在各裝置上具有一致的效能與使用者體驗。設計時著重於簡潔與客製化,能順暢整合至現有的 Flutter 項目。

適用情境

  • 社交媒體應用程式照片上傳
  • 電子商務產品圖片選擇
  • 用戶個人檔案圖片和影片上傳
  • 內容創作工具與媒體批量處理
  • 多媒體表單提交

主要特色

  • Instagram 風格的使用者介面
  • 多選圖片和影片
  • 圖像和影片裁剪
  • 可自訂的寬高比
  • Android 和 iOS 的原生效能

適合對象

  • 開發社交應用的開發者
  • 需要高級媒體選擇的應用程式
  • 需要批量媒體處理的項目
  • 以使用者體驗為導向的行動應用程式
  • Flutter 開發者想要原生樣式的選擇器

使用建議

  • 需要平台特定權限以存取媒體
  • 由於原生依賴項,可能導致應用體積增加
  • 僅限影像與影片類型
  • 裁剪功能可能需要額外設定
  • 不適用於非媒體檔案選擇

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Instagram Assets Picker

Pub Flutter lints Gitmoji

An image (also with videos) picker based on Instagram picker UI. It is using the powerful flutter_wechat_assets_picker package to handle the picker and a custom version of image_crop for crop.

🚀 Features

  • ✅ Instagram layout
    • Scroll behaviors, animation
    • Preview, select, unselect action logic
  • ✅ Image and Video (but not video processing) support
  • ✅ Theme and language customization
  • ✅ Multiple assets pick (with maximum limit)
  • ✅ Single asset pick mode
  • ✅ Restore state of picker after pop
  • ✅ Select aspect ratios to crop all assets with (default to 1:1 & 4:5)
  • ✅ Crop all image assets at once and receive a stream with a progress value
  • ✅ Prepend or append a custom item in the assets list
  • ✅ Add custom action buttons

📸 Screenshots

Layout and scroll Crop

📖 Installation

Add this package to the pubspec.yaml

insta_assets_picker: ^3.4.0
‼️ DO NOT SKIP THIS PART

Since this package is a custom delegate of flutter_wechat_assets_picker you MUST follow this package setup recommendation : installation guide.

👀 Usage

For more details check out the example.

Future<List<AssetEntity>?> callPicker() => InstaAssetPicker.pickAssets(
    context,
    pickerConfig: InstaAssetPickerConfig(
      title: 'Select assets',
    ),
    maxAssets: 10,
    onCompleted: (Stream<InstaAssetsExportDetails> stream) {
        // TODO : handle crop stream result
        // i.e : display it using a StreamBuilder
        // - in the same page (closeOnComplete=true)
        // - send it to another page (closeOnComplete=false)
        // or use `stream.listen` to handle the data manually in your state manager
        // - ...
    },
);

Fields in InstaAssetsExportDetails:

Name Type Description
data List<InstaAssetsExportData> Contains the selected assets, crop parameters and possible crop file.
selectedAssets List<AssetEntity> Selected assets without crop
aspectRatio double Selected aspect ratio (1 or 4/5)
progress double Progress indicator of the exportation (between 0 and 1)

Fields in InstaAssetsExportData:

Name Type Description
croppedFile File? The cropped file. Can be null if video or if choose to skip crop.
selectedData InstaAssetsCropData The selected asset and it's crop parameter (area, scale, ratio...)
Picker configuration

Please follow flutter_wechat_assets_picker documentation : AssetPickerConfig

Localizations

Please follow flutter_wechat_assets_picker documentation : Localizations

Theme customization

Most of the components of the picker can be customized using theme.

// set picker theme based on app theme primary color
final theme = InstaAssetPicker.themeData(Theme.of(context).primaryColor);
InstaAssetPicker.pickAssets(
    context,
    pickerConfig: InstaAssetPickerConfig(
      pickerTheme: theme.copyWith(
        canvasColor: Colors.black, // body background color
        splashColor: Color.grey, // ontap splash color
        colorScheme: theme.colorScheme.copyWith(
          background: Colors.black87, // albums list background color
        ),
        appBarTheme: theme.appBarTheme.copyWith(
          backgroundColor: Colors.black, // app bar background color
          titleTextStyle: Theme.of(context)
              .appBarTheme
              .titleTextStyle
              ?.copyWith(color: Colors.white), // change app bar title text style to be like app theme
        ),
        // edit `confirm` button style
        textButtonTheme: TextButtonThemeData(
          style: TextButton.styleFrom(
            foregroundColor: Colors.blue,
            disabledForegroundColor: Colors.red,
          ),
        ),
      ),
    ),
    onCompleted: (_) {},
);
Crop customization

You can set the list of crop aspect ratios available. You can also set the preferred size, for the cropped assets.

InstaAssetPicker.pickAssets(
    context,
    pickerConfig: InstaAssetPickerConfig(
      cropDelegate: InstaAssetCropDelegate(
        // allows you to set the preferred size used when cropping the asset.
        // the final size will depends on the scale used when cropping.
        preferredSize: 1080,
        cropRatios: [
        // - allow you to set the list of aspect ratios selectable,
        // the default values are [1/1, 4/5] like instagram.
        // - if you want to disable cropping, you can set only one parameter,
        // in this case, the "crop" button will not be displayed (#10).
        // - if the value of cropRatios is different than the default value,
        // the "crop" button will display the selected ratio value (i.e.: 1:1)
        // instead of unfold arrows.
      ]),
    ),
    onCompleted: (_) {},
);
Camera

Many people requested the ability to take picture from the picker. The main aspect of this package is selection and uniform crop selection. Consequently, camera-related operations have no place in this package. However, since version 2.0.0, it is now possible to trigger this action using either specialItemBuilder and/or actionsBuilder.

The ability to take a photo from the camera must be handled on your side, but the picker is now able to refresh the list and select the new photo. New examples have been written to show how to manage this process with the camera or wechat_camera_picker package.

Video

Video are now supported on version 3.0.0. You can pick a video asset and select the crop area directly in the picker. However, as video processing is a heavy operation it is not handled by this package. Which means you must handle it yourself. If you want to preview the video result, you can use the InstaAssetCropTransform which will transform the Image or VideoPlayer to fit the selected crop area.

The example app has been updated to support videos (+ camera recording) and shows how to process the video using the now retired ffmpeg_kit_flutter.

✨ Credit

This package is based on flutter_wechat_assets_picker by AlexV525 and image_crop by lykhonis.

所屬分類

依賴

依賴清單 8 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。