먼저 로컬 파일을 확인하여 이미지 로딩을 효율적으로 관리하는 플러터 패키지입니다. 이미지가 로컬에 없으면 네트워크에서 다운로드하여 디스크에 저장해 향후 사용하기 위해 활용함으로써 중복 다운로드를 줄이고 성능을 향상시킵니다. 최소한의 설정으로 지속적인 이미지 캐싱이 필요한 앱에 적합합니다.
사용 사례
오프라인 액세스를 위한 원격 이미지 캐싱
반복적인 네트워크 요청 줄이기
로컬 저장소를 통한 앱 성능 향상
사용자 프로필 사진을 표시하고 대체 옵션 제공
지속성과 함께 목록 뷰에서 이미지 로드
주요 기능
네트워크 가져오기 전 로컬 파일 확인
다운로드 후 자동 이미지 저장
내장 캐싱 메커니즘
다수의 플랫폼을 지원합니다
간단한 API 통합
적합한 대상
오프라인 이미지 사용이 필요한 앱
이미지 중심 애플리케이션
경량 캐싱을 찾는 개발자
제한된 백엔드 인프라를 갖춘 프로젝트
모바일 및 데스크톱 플랫폼 대상 앱
고려 사항
일부 플랫폼에서는 파일 시스템 권한이 필요합니다
디스크 공간 사용량은 시간이 지남에 따라 증가합니다
내장된 만료 또는 정리 전략 없음
수동 캐시 관리가 필요할 수 있습니다
캐시 크기 또는 TTL에 대한 제어가 제한됨
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
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.