Kategorien, Pakete und Repositories suchen

Paketdetailsv2.0.0

cached_network_svg_image

Ein Flutter-Paket zum Cachen von SVG-Bildern.

AndroidiOSWebmacOSWindowsLinux
30-Tage-Downloads
25.700
Likes
58
Pub-Punkte
120

Paket installieren

flutter pub add cached_network_svg_image

Paketübersicht

Aus öffentlichen Paketdaten erstellte Orientierung.

Ein Flutter-Paket, das effizient SVG-Bilder aus dem Web laden und zwischenspeichern soll. Es vereinfacht die Anzeige skalierbarer Vektorgrafiken in Flutter-Anwendungen, indem es Netzwerkanfragen, Caching und Rendern mit minimalem Boilerplate verwaltet. Das Paket unterstützt mehrere Plattformen wie Android, iOS, Web, macOS, Windows und Linux und sorgt für konsistentes Verhalten über Geräte hinweg. Es verbessert die Leistung, indem es redundanten Downloads verringert und die Bildladezeiten durch lokale Caching-Techniken beschleunigt.

Anwendungsfälle

  • Skalierbare Icons von URLs anzeigen
  • Remote SVG-Ressourcen für den Offline-Gebrauch zwischenspeichern
  • Verbesserung der App-Leistung mit zwischengespeicherten Vektorgrafiken
  • Laden von SVGs in plattformübergreifenden Flutter-Anwendungen
  • Bandbreitennutzung bei wiederholten Bildlastvorgängen verringern

Hauptmerkmale

  • Automatisches Caching heruntergeladener SVGs
  • Unterstützung für alle wichtigen Flutter-Plattformen
  • Effizienter Speicher- und Festplattennutzung
  • Einfache Integration mit bestehendem Flutter-Code
  • Eingebaute Fehlerbehandlung und Wiederholungslogik

Geeignet für

  • Apps, die häufiges Laden von SVG-Bildern erfordern
  • Entwickler, die optimierte Bildleistung suchen
  • Plattformübergreifende Projekte mit Vektorgrafiken
  • Anwendungen mit Fokus auf Offline-Funktionalität
  • Teams, die saubere, wiederverwendbare Bildkomponenten priorisieren

Hinweise

  • Internetverbindung für den ersten Download erforderlich
  • Die Cache-Verwaltung erfordert möglicherweise eine manuelle Bereinigung
  • Große SVG-Dateien können die Ladezeit beeinträchtigen
  • Eingeschränkte Anpassungsmöglichkeiten für SVG-Rendereinstellungen
  • Abhängig von der Stabilität der zugrunde liegenden SVG-Parsbibliothek

Original-README

Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.

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.

Kategorien

Abhängigkeiten

Abhängigkeiten 2 Einträge

Quell-Repository

Projekte, die dieses Paket verwenden