분류, 패키지 및 저장소 검색

패키지 상세v2.0.0

cached_network_svg_image

SVG 이미지를 캐싱하기 위한 Flutter 패키지입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
2.6만
좋아요
58
Pub 점수
120

패키지 설치

flutter pub add cached_network_svg_image

패키지 개요

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

웹에서 SVG 이미지를 효율적으로 로드하고 캐시하기 위해 설계된 플러터 패키지입니다. 네트워크 요청, 캐싱, 렌더링을 최소한의 보일러플레이트로 처리하여 플러터 앱에서 확장 가능한 벡터 그래픽을 쉽게 표시할 수 있도록 합니다. Android, iOS, Web, macOS, Windows, Linux 등 여러 플랫폼을 지원하며 장치 간 일관된 동작을 보장합니다. 로컬 캐싱을 통해 중복 다운로드를 줄이고 이미지 로드 시간을 개선하여 성능을 향상시킵니다.

사용 사례

  • URL에서 확장 가능한 아이콘 표시
  • 오프라인 사용을 위해 원격 SVG 자산 캐싱
  • 캐시된 벡터 그래픽을 활용한 앱 성능 향상
  • 크로스 플랫폼 플러터 애플리케이션에서 SVG 로드하기
  • 반복된 이미지 로드에 대한 대역폭 사용량 줄이기

주요 기능

  • 다운로드된 SVG의 자동 캐싱
  • 모든 주요 플러터 플랫폼 지원
  • 효율적인 메모리 및 디스크 사용
  • 기존 Flutter 코드와의 간단한 통합
  • 내장된 오류 처리 및 재시도 로직

적합한 대상

  • 자주 SVG 이미지를 로드해야 하는 앱
  • 최적화된 이미지 성능을 찾는 개발자
  • 벡터 그래픽을 사용하는 크로스 플랫폼 프로젝트
  • 오프라인 기능을 타겟으로 하는 애플리케이션
  • 클린하고 재사용 가능한 이미지 컴포넌트를 우선 고려하는 팀

고려 사항

  • 초기 다운로드를 위해 인터넷 연결이 필요합니다
  • 캐시 관리는 수동으로 정리해야 할 수도 있습니다
  • 큰 SVG 파일은 초기 로드 시간에 영향을 줄 수 있습니다
  • SVG 렌더링 옵션에 대한 사용자 정의 제한
  • 하위 SVG 파싱 라이브러리의 안정성에 따라 달라집니다

원본 README

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

Cached Network SVG Image

cached_network_svg_image is a Flutter package that allows you to easily load and cache SVG images from the network. It provides a simple and efficient way to display SVG images with caching, placeholders, and error handling. 🌐🖼️ Now supports Web! 🌍

Features ✨

  • Load SVG images from the network. 🌍
  • Cache images for offline use. 📦
  • Display a placeholder while the image is loading. ⏳
  • Show an error widget if the image fails to load. ❌
  • Customize the fade-in duration for the image. ⏱️

Installation 🛠️

Add the following to your pubspec.yaml file:

dependencies:
  cached_network_svg_image: any

Then, run flutter pub get to install the package. 🚀

Usage 📖

Import the package in your Dart file:

import 'package:cached_network_svg_image/cached_network_svg_image.dart';

Use the CachedNetworkSVGImage widget to display an SVG image from the network:

CachedNetworkSVGImage(
    imageUrl: 'https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg',
    placeholder: const CircularProgressIndicator(color: Colors.green),
    errorWidget: const Icon(Icons.error, color: Colors.red),
    width: 250.0,
    height: 250.0,
    fadeDuration: const Duration(milliseconds: 500),
),
Parameters 📋
  • imageUrl: The URL of the SVG image. 🌐
  • cacheKey: A custom cache key to use for the image. 🔑
  • placeholder: A widget to display while the image is loading. ⏳
  • errorWidget: A widget to display if the image fails to load. ❌
  • width: The width of the image. 📏
  • height: The height of the image. 📏
  • fadeDuration: The duration of the fade-in animation when the image loads. ⏱️
  • headers: A map of headers to pass with the network request. 🗂️
  • cacheManager: A custom cache manager to use for caching the image, Default is DefaultCacheManager(). 📦
  • fit: How the image should be inscribed into the space allocated for it. 🔲
  • alignment: How the image should be aligned within its bounds. 📐
  • matchTextDirection: Whether to paint the image in the direction of the TextDirection. ↔️
  • allowDrawingOutsideViewBox: Whether to allow the image to draw outside its view box. 📏
  • color: The color to apply to the image. 🎨
  • colorBlendMode: The blend mode to apply to the image color. 🎨
  • semanticsLabel: A description of the image for accessibility tools. 🏷️
  • excludeFromSemantics: Whether the image should be excluded from semantics. 🚫
  • colorFilter: A color filter to apply to the image. 🎨
  • placeholderBuilder: A builder function to create the placeholder widget. 🛠️
  • theme: The theme to apply to the image. 🎨
Functions 🔧
  • preCache: A function to pre-cache the image. 📦
  • clearCacheForUrl: A function to clear the cache for a specific URL. 🗑️
  • clearCache: A function to clear the entire cache. 🗑️

Example 💡

Here is a complete example of how to use the cached_network_svg_image package:

import 'package:flutter/material.dart';
import 'package:cached_network_svg_image/cached_network_svg_image.dart';

void main() {
    runApp(MyApp());
}

class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
        return MaterialApp(
            home: Scaffold(
                appBar: AppBar(
                    title: Text('Cached Network SVG Image Example'),
                ),
                body: Center(
                    child: CachedNetworkSVGImage(
                        imageUrl: 'https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg',
                        placeholder: const CircularProgressIndicator(color: Colors.green),
                        errorWidget: const Icon(Icons.error, color: Colors.red),
                        width: 250.0,
                        height: 250.0,
                        fadeDuration: const Duration(milliseconds: 500),
                    ),
                ),
            ),
        );
    }
}

License 📄

This project is licensed under the MIT License. See the LICENSE file for more details.

카테고리

의존성

의존성 목록 2 개

소스 저장소

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