Buscar pacotes, repositórios e categorias de apps

Detalhes do pacotev3.0.1

optimized_cached_image

Uma biblioteca para carregar imagens da rede, redimensionar conforme o tamanho do contêiner e armazenar em cache com sensibilidade à memória.

Downloads em 30 dias
355
Curtidas
114
Pontos Pub
60

Instalar pacote

flutter pub add optimized_cached_image

Visão geral do pacote

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

OptimizedCachedImage é um pacote Flutter projetado para carregar, redimensionar e armazenar em cache imagens da rede de forma eficiente, minimizando o uso de memória. Ele ajusta automaticamente o tamanho da imagem para corresponder às dimensões do contêiner, reduzindo o consumo desnecessário de memória. A biblioteca garante desempenho suave aproveitando mecanismos de cache e otimizando o manuseio de recursos. Ideal para aplicativos com carregamento frequente de imagens, equilibra velocidade e eficiência sem comprometer a experiência do usuário.

Casos de uso

  • Carregando imagens dinâmicas de URLs
  • Redimensionar imagens para se ajustar às dimensões do contêiner
  • Armazenando em cache imagens para reduzir solicitações de rede
  • Reduzindo o uso de memória em aplicativos com muitas imagens
  • Melhorando o desempenho do aplicativo com manipulação eficiente de imagens

Principais recursos

  • Redimensionamento automático de imagem
  • armazenamento em cache eficiente em memória
  • Carregamento de imagem de rede
  • Dimensionamento consciente de contêineres
  • Baixo custo de memória

Indicado para

  • Aplicativos com alto tráfego de imagem
  • UIs críticas para o desempenho
  • Aplicativos móveis com memória limitada
  • Galerias de imagens e feeds
  • Aplicativos de comércio eletrônico ou mídia social

Considerações

  • Requer acesso à internet para o carregamento inicial
  • Pode ser necessário configurar políticas de cache personalizadas
  • Otimizações específicas de plataforma limitadas
  • Não adequado para imagens locais estáticas
  • Depende da confiabilidade da rede externa

README original

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

Optimized Cached Image

pub package

❌❌ Important Update ❌❌

This library is no longer being maintained. When I started this library, it was meant to add memory performant extensions which could not be directly added into the parent library. Since then a lot has changed, the parent library has incorporated similar changes, perhaps with the exception of a trivial LayoutBuilder that auto detects image sizes. I feel like this is a good time to deprecate this library in favour of the parent.

Description

A flutter library for loading images from network, resizing and caching them for memory sensitivity. This resizes and stores the images in cache based on parent container constraints and hence loads images of lower size into memory. This is heavily inspired by cached_network_image library.

This library exposes two classes for loading images

  • OptimizedCacheImage which is a 1:1 mapping of CachedNetworkImage.
  • OptimizedCacheImageProvider which is a mapping of CachedNetworkImageProvider.

How to use

The OptimizedCacheImage can be used directly or through the ImageProvider. Both the OptimizedCacheImage as OptimizedCacheImageProvider have minimal support for web. It currently doesn't include caching.

With a placeholder:

OptimizedCacheImage(
        imageUrl: "http://via.placeholder.com/350x150",
        placeholder: (context, url) => CircularProgressIndicator(),
        errorWidget: (context, url, error) => Icon(Icons.error),
     ),

Or with a progress indicator:

OptimizedCacheImage(
       imageUrl: "http://via.placeholder.com/350x150",
       progressIndicatorBuilder: (context, url, downloadProgress) =>
               CircularProgressIndicator(value: downloadProgress.progress),
       errorWidget: (context, url, error) => Icon(Icons.error),
    ),
Image(image: OptimizedCacheImageProvider(url))

When you want to have both the placeholder functionality and want to get the imageprovider to use in another widget you can provide an imageBuilder:

OptimizedCacheImage(
  imageUrl: "http://via.placeholder.com/200x150",
  imageBuilder: (context, imageProvider) => Container(
    decoration: BoxDecoration(
      image: DecorationImage(
          image: imageProvider,
          fit: BoxFit.cover,
          colorFilter:
              ColorFilter.mode(Colors.red, BlendMode.colorBurn)),
    ),
  ),
  placeholder: (context, url) => CircularProgressIndicator(),
  errorWidget: (context, url, error) => Icon(Icons.error),
),

Handling Gifs

OCI uses Flutter Image Compress as the compression library, while being memory efficient this library doesn't provide out of box support for gifs, however it does allow compressing to webp. Hence all gifs are compressed to webp format beginning 2.0.2-alpha.

How it works

The optimized cached network images stores and retrieves files using the flutter_cache_manager.

FAQ

My app crashes when the image loading failed. (I know, this is not really a question.)

Does it really crash though? The debugger might pause, as the Dart VM doesn't recognize it as a caught exception; the console might print errors; even your crash reporting tool might report it (I know, that really sucks). However, does it really crash? Probably everything is just running fine. If you really get an app crashes you are fine to report an issue, but do that with a small example so we can reproduce that crash.

Categorias

Dependências

Lista de dependências 11 itens

Repositório-fonte

Projetos que usam este pacote

Ainda não há dados.