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

패키지 상세v4.0.6

cached_network_image

네트워크 이미지를 로드하고 캐시하는 데 사용할 수 있는 플러터 라이브러리입니다. 플레이스홀더 및 오류 위젯과 함께 사용할 수도 있습니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
366만
좋아요
7천
Pub 점수
150

패키지 설치

flutter pub add cached_network_image

패키지 개요

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

네트워크 이미지를 효율적으로 로드하고 캐시하는 데 사용할 수 있는 플러터 패키지로, 자리 표시자 및 오류 위젯을 지원합니다. 이미지를 로컬에 저장함으로써 중복 다운로드를 줄이고 앱 성능을 향상시키며 대역폭 사용량을 줄입니다. 소셜 미디어 피드나 제품 카탈로그와 같이 원격 소스에서 많은 이미지를 표시하는 앱에 적합합니다. 이 라이브러리는 이미지 로딩을 비동기적으로 처리하며, 로딩 상태 및 실패 시 사용자 정의 가능한 UI를 제공합니다.

사용 사례

  • 앱에서 동적 이미지 콘텐츠 표시
  • 원격 서버에서 이미지를 효율적으로 로드하기
  • 로딩 중에 자리 표시 이미지 표시
  • 이미지 로드 실패를 유연하게 처리하기
  • 로컬 캐싱을 통한 데이터 사용량 감소
  • 이미지 중심 사용자 인터페이스 구축

주요 기능

  • 자동 이미지 캐싱
  • 사용자 정의 가능한 자리 표시자 및 오류 위젯
  • 모든 주요 플랫폼 지원
  • 효율적인 메모리 및 디스크 관리
  • 비동기 이미지 로딩
  • 사용자 정의 가능한 캐시 크기 및 기간

적합한 대상

  • 자주 이미지를 가져오는 앱
  • 성능과 사용자 경험을 우선시하는 개발자
  • 오프라인 이미지 접근이 필요한 프로젝트
  • 소셜 미디어 및 전자상거래 애플리케이션
  • 다중 플랫폼을 대상으로 하는 앱

고려 사항

  • 저장 문제를 방지하기 위해 적절한 캐시 관리가 필요합니다
  • 대규모 이미지 세트에 맞게 조정이 필요할 수 있습니다
  • 플랫폼별 동작은 약간 다를 수 있습니다
  • 초기 설정을 위해서 캐싱 전략에 대한 이해가 필요합니다
  • 매우 작은 정적 이미지 컬렉션에는 적합하지 않습니다

원본 README

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

Cached network image

pub package codecov Build Status

A flutter library to show images from the internet and keep them in the cache directory.

Sponsors


Try the Flutter Chat Tutorial 💬

How to use

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

With a placeholder:

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

Or with a progress indicator:

CachedNetworkImage(
       imageUrl: "http://via.placeholder.com/350x150",
       progressIndicatorBuilder: (context, url, downloadProgress) => 
               CircularProgressIndicator(value: downloadProgress.progress),
       errorWidget: (context, url, error) => Icon(Icons.error),
    ),
Image(image: CachedNetworkImageProvider(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:

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

How it works

The 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.

See for example this or this answer on previous posted issues.

카테고리

의존성

의존성 목록 5 개

소스 저장소

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