Buscar pacotes, repositórios e categorias de apps

Detalhes do pacotev2.2.1

photo_gallery

Um plugin Flutter que recupera imagens e vídeos da galeria nativa do dispositivo móvel.

AndroidiOS
Downloads em 30 dias
2,3 mil
Curtidas
162
Pontos Pub
150

Instalar pacote

flutter pub add photo_gallery

Visão geral do pacote

Orientação gerada a partir de informações públicas. Apenas para referência.

O pacote photo_gallery é um plugin do Flutter projetado para acessar imagens e vídeos da galeria nativa em dispositivos Android e iOS. Ele fornece uma interface simples para recuperar arquivos multimídia, permitindo que desenvolvedores integrem navegação e seleção de galeria em seus aplicativos. O plugin utiliza APIs específicas da plataforma para garantir compatibilidade e desempenho em ambos os sistemas operacionais. É ideal para aplicações que exigem funcionalidades de coleta de mídia, como compartilhamento de fotos, upload de fotos de perfil ou ferramentas de criação de conteúdo. Com configuração mínima via pub add, oferece integração sem problemas em projetos Flutter existentes.

Casos de uso

  • Seleção de imagem e vídeo da galeria do dispositivo
  • Fluxos de trabalho de upload de imagem de perfil
  • Criação de conteúdo de aplicativo rico em mídia
  • Desenvolvimento de aplicativo de compartilhamento de fotos
  • coleta de conteúdo gerado pelo usuário

Principais recursos

  • Suporte multiplataforma para Android e iOS
  • API simples para acessar mídia da galeria nativa
  • Suporta imagens e vídeos
  • Integração fácil com flutter pub add
  • Depende de APIs nativas da plataforma para confiabilidade

Indicado para

  • Desenvolvedores criando aplicativos Flutter com muitos recursos multimídia
  • Aplicativos que precisam de acesso à galeria para uploads de usuários
  • Plataformas de mídia social ou criação de conteúdo
  • Aplicativos móveis que exigem funcionalidade de seleção de imagem/vídeo
  • Projetos com prioridade para integração nativa da galeria

Considerações

  • Permissões apropriadas são necessárias no Android e no iOS
  • Limitado à recuperação de mídia; sem edição ou corte
  • Depende da disponibilidade da galeria nativa e das permissões do sistema
  • Pode exigir tratamento adicional para arquivos de mídia grandes
  • Não adequado para tarefas avançadas de processamento de mídia

README original

Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.

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,
    ),
)

Categorias

Repositório-fonte

Projetos que usam este pacote