패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.2.1

photo_gallery

모바일 네이티브 갤러리에서 이미지와 비디오를 검색하는 Flutter 플러그인입니다.

AndroidiOS
30일 다운로드
2.3천
좋아요
162
Pub 점수
150

패키지 설치

flutter pub add photo_gallery

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

photo_gallery 패키지는 Android 및 iOS 기기의 네이티브 갤러리에서 이미지와 비디오에 액세스하기 위해 설계된 플러터 플러그인입니다. 미디어 파일을 검색하는 간단한 인터페이스를 제공하여 개발자가 앱에 갤러리 브라우징 및 선택 기능을 통합할 수 있도록 합니다. 플랫폼별 API를 활용하여 두 운영 체제 모두에서 호환성과 성능을 보장합니다. 사진 공유, 프로필 사진 업로드, 콘텐츠 생성 도구와 같은 미디어 수집 기능이 필요한 애플리케이션에 적합합니다. pub add를 통해 최소한의 설정으로 기존 플러터 프로젝트에 원활하게 통합할 수 있습니다.

사용 사례

  • 기기 갤러리에서 이미지 및 비디오 선택
  • 프로필 사진 업로드 워크플로우
  • 미디어 풍부한 앱 콘텐츠 제작
  • 사진 공유 애플리케이션 개발
  • 사용자 생성 콘텐츠 수집

주요 기능

  • Android 및 iOS용 크로스 플랫폼 지원
  • 네이티브 갤러리 미디어에 접근하는 간단한 API
  • 이미지와 동영상 둘 다 지원
  • flutter pub add와의 간편한 통합
  • 신뢰성을 위해 네이티브 플랫폼 API에 의존합니다

적합한 대상

  • 미디어 중심의 플러터 앱을 개발하는 개발자
  • 사용자 업로드를 위해 갤러리 액세스가 필요한 앱
  • 소셜 미디어 또는 콘텐츠 제작 플랫폼
  • 이미지/비디오 선택 기능을 필요로 하는 모바일 앱
  • 네이티브 갤러리 통합을 우선 고려하는 프로젝트

고려 사항

  • Android 및 iOS에 적절한 권한이 필요합니다
  • 미디어 가져오기만 가능; 편집 또는 자르기 불가
  • 네이티브 갤러리의 사용 가능성 및 시스템 권한에 따라 다릅니다
  • 큰 미디어 파일 처리를 위해 추가적인 조치가 필요할 수 있습니다
  • 고급 미디어 처리 작업에 적합하지 않습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Photo Gallery

pub package

A Flutter plugin that retrieves images and videos from mobile native gallery.

Installation

First, add photo_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:

NSPhotoLibraryUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor.

<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:

<manifest ...>
    <uses-permission
        android:name="android.permission.READ_EXTERNAL_STORAGE"
        android:maxSdkVersion="32" />
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<manifest/>

Usage

  • Listing albums in the gallery
final List<Album> imageAlbums = await PhotoGallery.listAlbums();
final List<Album> videoAlbums = await PhotoGallery.listAlbums(
    mediumType: MediumType.video,
    newest: false,
    hideIfEmpty: false,
);
  • Listing media in an album
final MediaPage imagePage = await imageAlbum.listMedia();
final MediaPage videoPage = await imageAlbum.listMedia(
    skip: 5,
    take: 10,
);
final List<Medium> allMedia = [
    ...imagePage.items,
    ...videoPage.items,
];
  • Loading more media in a album
if (!imagePage.isLast) {
    final nextImagePage = await imagePage.nextPage();
    // ...
}
  • Getting a Medium
final Medium medium = await PhotoGallery.getMedium(
  mediumId: "10",
  mediumType: MediumType.image
);
  • Getting a file
final File file = await medium.getFile();
final File file = await PhotoGallery.getFile(mediumId: mediumId);
  • Getting thumbnail data
final List<int> data = await medium.getThumbnail();
final List<int> data = await PhotoGallery.getThumbnail(mediumId: mediumId);

You can also specify thumbnail width and height on Android API 29 or higher; You can also specify thumbnail width, height and whether provider high quality or not on iOS:

final List<int> data = await medium.getThumbnail(
    width: 128,
    height: 128,
    highQuality: true,
);
final List<int> data = await PhotoGallery.getThumbnail(
    mediumId: mediumId,
    mediumType: MediumType.image,
    width: 128,
    height: 128,
    highQuality: true,
);
  • Getting album thumbnail data
final List<int> data = await album.getThumbnail();
final List<int> data = await PhotoGallery.getAlbumThumbnail(albumId: albumId);

You can also specify thumbnail width and height on Android API 29 or higher; You can also specify thumbnail width, height and whether provider high quality or not on iOS:

final List<int> data = await album.getThumbnail(
    width: 128,
    height: 128,
    highQuality: true,
);
final List<int> data = await PhotoGallery.getAlbumThumbnail(
    albumId: albumId,
    mediumType: MediumType.image,
    newest: false,
    width: 128,
    height: 128,
    highQuality: true,
);
  • Displaying medium thumbnail

ThumbnailProvider are available to display thumbnail images (here with the help of dependency transparent_image):

FadeInImage(
    fit: BoxFit.cover,
    placeholder: MemoryImage(kTransparentImage),
    image: ThumbnailProvider(
        mediumId: mediumId,
        mediumType: MediumType.image,
        width: 128,
        height: 128,
        hightQuality: true,
    ),
)

Width and height is only available on Android API 29+ or iOS platform

  • Displaying album thumbnail

AlbumThumbnailProvider are available to display album thumbnail images (here with the help of dependency transparent_image):

FadeInImage(
    fit: BoxFit.cover,
    placeholder: MemoryImage(kTransparentImage),
    image: AlbumThumbnailProvider(
        album: album,
        width: 128,
        height: 128,
        hightQuality: true,
    ),
)

Width and height is only available on Android API 29+ or iOS platform. High quality is only available on iOS platform.

  • Displaying a full size image

You can use PhotoProvider to display the full size image (here with the help of dependency transparent_image):

FadeInImage(
    fit: BoxFit.cover,
    placeholder: MemoryImage(kTransparentImage),
    image: PhotoProvider(
        mediumId: mediumId,
    ),
)

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트