パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.1.5

media_gallery

ネイティブギャラリー項目をリストアップするFlutterプラグイン。

30日間ダウンロード
28
いいね数
31
Pub ポイント
30

パッケージをインストール

flutter pub add media_gallery

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

media_gallery パッケージは、Flutter プラグインであり、ネイティブデバイスのギャラリー項目にアクセスできるようにし、ユーザーがデバイスのローカルメディアストレージから画像や動画を閲覧および選択できるようにします。ファイルパス、タイムスタンプ、寸法などのメタデータを含むメディアファイルを取得するためのシンプルなインターフェースを提供します。Flutterアプリとのシームレスな統合を目的としており、AndroidおよびiOSでのプラットフォーム固有の実装をサポートしています。写真共有、プロフィール画像のアップロード、コンテンツ作成ツールなど、メディア選択機能が必要なアプリケーションに最適です。パフォーマンスと互換性のためにネイティブAPIに依存しています。

用途

  • デバイスギャラリーからの画像および動画の選択
  • プロフィール画像のアップロードワークフロー
  • メディア豊富なアプリコンテンツ作成
  • Flutterアプリでの写真アルバムの閲覧
  • Flutter UIにネイティブメディアピッカーを統合する

主な機能

  • ネイティブデバイスのメディアファイルへのアクセス
  • 画像と動画の両方をサポートしています
  • メディアメタデータ(パス、タイムスタンプ、サイズ)を取得します
  • クロスプラットフォーム互換性(Android/iOS)
  • メディアのリスト表示とフィルタリング用のシンプルな API

適している対象

  • メディア選択が必要なFlutterアプリ
  • ソーシャルメディアまたは写真共有プラットフォーム
  • コンテンツ作成ツール
  • ユーザーが生成したメディアのアップロードを含むアプリ
  • カスタムメディアピッカーを構築する開発者

注意事項

  • 適切な権限(カメラおよびストレージ)が必要です
  • ネイティブギャラリーのみ対応;クラウドメディアはサポートされていません
  • プラットフォーム固有の動作は異なる場合があります
  • 組み込みのUIコンポーネントなし;カスタム実装が必要
  • 大規模なメディアライブラリには追加の処理が必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Media Gallery plugin for Flutter

pub package

A Flutter plugin that lists native gallery items.

Installation

First, add media_gallery as a dependency in your pubspec.yaml file.

iOS

Add the following keys to your Info.plist file, located in <project root>/ios/Runner/Info.plist:

<key>NSPhotoLibraryUsageDescription</key>
<string>Example usage description</string>
Android

Add the following permissions to your AndroidManifest.xml, located in <project root>/android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

You should also manage those permissions (for example thanks to the permission_handler plugin). You can see an example for more details.

Usage
Listing media collections
final List<MediaCollection> collections = await MediaGallery.listMediaCollections(
    mediaTypes: [MediaType.image, MediaType.video],
);
Listing medias in a collection
final MediaPage imagePage = await collection.getMedias(
    mediaType: MediaType.image,
    take: 500,
);
final MediaPage videoPage = await collection.getMedias(
    mediaType: MediaType.video,
    take: 500,
);
final List<Media> allMedias = [
    ...imageRange.items,
    ...videoRange.items,
]
..sort((x, y) => y.creationDate.compareTo(x.creationDate));
Loading more medias in a collection
if (!imagePage.isLast) {
    final nextImagePage = await imagePage.nextPage();
    // ...
}
Getting a file
final File file = await media.getFile();
Getting thumbnail data
final List<int> data = await media.getThumbnail();
Displaying thumbnails

MediaThumbnailProvider, MediaCollectionThumbnailProvider are available to display thumbnail images (here with the help of transparent_image) :

FadeInImage(
    fit: BoxFit.cover,
    placeholder: MemoryImage(kTransparentImage),
    image: MediaThumbnailProvider(
        media: media,
    ),
)
Displaying medias

You can use MediaImageProvider to display an image (here with the help of transparent_image):

FadeInImage(
    fit: BoxFit.cover,
    placeholder: MemoryImage(kTransparentImage),
    image: MediaImageProvider(
        media: media,
    ),
)

To display a video, you can use video_player.

Image/Video picker

picker

You can build a gallery picker easily with this package.

See the example for more details.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト