Orientação gerada a partir de informações públicas. Apenas para referência.
Um pacote Flutter que gerencia com eficiência o carregamento de imagens verificando primeiro um arquivo local. Se a imagem não for encontrada localmente, ela é baixada da rede e salva no disco para uso futuro, reduzindo downloads redundantes e melhorando o desempenho. Ideal para aplicativos que exigem cache persistente de imagens com configuração mínima.
Casos de uso
Armazenando em cache imagens remotas para acesso offline
Reduzindo solicitações de rede repetidas
Melhorando o desempenho do aplicativo com armazenamento local
Exibindo imagens de perfil do usuário com alternativas
Carregar imagens em visualizações de lista com persistência
Principais recursos
Verificação de arquivo local antes da busca na rede
Salvamento automático de imagem após o download
Mecanismo de cache embutido
Suporta múltiplas plataformas
Integração de API simples
Indicado para
Aplicativos que precisam de disponibilidade de imagem offline
Aplicações com muitas imagens
Desenvolvedores procurando cache leve
Projetos com infraestrutura de back-end limitada
Aplicativos direcionados para plataformas móveis e de desktop
Considerações
Requer permissões de sistema de arquivos em algumas plataformas
O uso do espaço em disco aumenta com o tempo
Sem estratégia interna de expiração ou limpeza
Pode ser necessário gerenciamento manual do cache
Controle limitado sobre o tamanho do cache ou TTL
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
network_to_file_image
This package combines NetworkImage and FileImage to:
Download the image once from the URL,
Save it to the local file system,
Use the saved image from the file system from then on.
In more detail:
Given a file and url of an image, it first tries to read it from the local file. It decodes the
given File object as an image, associating it with the given scale.
However, if the image doesn't yet exist as a local file, it fetches the given URL from the network,
associating it with the given scale, and then saves it to the local file. The image will be cached
regardless of cache headers from the server.
Notes:
If the provided url is null or empty, NetworkToFileImage will default to FileImage. It will
read the image from the local file, and won't try to download it from the network.
If the provided file is null, NetworkToFileImage will default to NetworkImage. It will
download the image from the network, and won't save it locally.
You can set mock files (local and in the network). Please see methods:
setMockFile(File file, Uint8List bytes)
setMockUrl(String url, Uint8List bytes)
clearMocks()
clearMockFiles()
clearMockUrls()
Your mocked urls are usually only seen by the NetworkToFileImage class. However, you may override
the default Dart http methods so that these urls are visible to other ImageProviders.