Aus öffentlichen Paketdaten erstellte Orientierung.
blurhash_ffi ist ein leistungsstarkes Flutter-Paket, das mithilfe nativer FFI-Bindings kompakte, visuell ansprechende verschwommene Bildplatzhalter generiert. Es kodiert und decodiert BlurHash-Zeichenfolgen effizient und ermöglicht eine schnelle Platzhalter-Rendierung ohne Abhängigkeit von reinen Dart-Implementierungen. Ideal zur Verbesserung der wahrgenommenen Leistung beim Bildladen, funktioniert auf Android, iOS, macOS, Windows und Linux. Das Paket legt Wert auf Geschwindigkeit und minimalen Speicherverbrauch, während die visuelle Qualität erhalten bleibt.
Anwendungsfälle
Ladebildschirm-Platzhalter
Bildgalerie-Vorschauen
Netzwerk-Bild-Ladeindikatoren
Platzhalter für Offline-Inhalte
Leistungsoptimierung in medienintensiven Apps
Hauptmerkmale
Native FFI-Leistung
Plattformübergreifende Unterstützung
Kompakte Hash-Codierung
Schnelle Dekodierung
Geringer Speicherverbrauch
Geeignet für
Apps mit starkem Bild-Ladeaufwand
Anforderungen an die Hochleistungs-UI
Entwickler, die native Geschwindigkeit suchen
Projekte, die leichte Platzhalter benötigen
Multiplattform-Flutter-Apps
Hinweise
Benötigt native Kompilierungs-Einrichtung
Nur im BlurHash-Format
Kann die App-Größe leicht erhöhen
Nicht geeignet für komplexe Bildverarbeitung
Abhängig von plattformspezifischen FFI-Bibliotheken
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
blurhash_ffi
A Blurhash compact Image placeholder encoder and decoder FFI implementation for Flutter in Rust via experemental feature Native Assets.
Matches the official Blurhash implementation in performance and quality.
Supports
Platform
Status
Description
Android
✅
-
iOS
✅
-
macOS
✅
-
Linux
⚠️
Not tested
Windows
✅
-
Web
❌
Rust can compiled to WebAssembly, but no supported yet. This library compiled on standalone wasm module (not in Empscripten, AssemblyScript) that Dart can't be use non-JS enviroments. Also, Dart should use FFI bindings for call wasm module. Stopped issues: comment
Installation
Add dependency to your pubspec.yaml file following the command below:
For dart projects:
dart pub add dart_blurhash_ffi
For flutter projects:
dart pub add flutter_blurhash_ffi
Usage
To use this plugin, add blurhash_ffi as a dependency in your pubspec.yaml file
Flutter usage
import'package:flutter_blurhash_ffi/flutter_blurhash_ffi.dart';
/// Encoding and Decoding all in One Step////// `ImageProvider` in -> Send your Image to be encoded./// `ImageProvider` out -> Get your blurry image version.classBlurhashMyImageextendsStatelessWidget{
finalString imageUrl;
constBlurhashMyImage({requiredthis.imageUrl, super.key});
@overrideWidgetbuild(BuildContext context) {
returnImage(
image: BlurhashFfiImage.fromImageProvider(
NetworkImage(imageUrl), // you can use any image provider of your choice.
decodingHeight: 1920,
decodingWidth: 1080,
),
alignment: Alignment.center,
fit: BoxFit.cover
);
}
}
classBlurhashMyImage2extendsStatelessWidget{
finalString blurhash;
constBlurhashMyImage2({requiredthis.blurhash, super.key});
@overrideWidgetbuild(BuildContext context) {
returnImage(
image: BlurhashFfiImage(blurhash),
width: 200,
height: 200,
alignment: Alignment.center,
fit: BoxFit.cover
);
}
}
[!WARNING]
Not recommend use it (without blurhash string param), because in this case, encoding and decoding will be performed. This effect can be obtained almost through ImageFiltered.
Encoding
Encoding now uses sync interface (without Future).
import'package:dart_blurhash_ffi/dart_blurhash_ffi.dart';
finalUint8List blurhashImageBytes = File('assets/image.webp').readAsBytesSync();
/// Signature/// static String encode(/// Uint8List data, {/// int componentX = 4,/// int componentY = 3,/// })/// may throw `BlurhashFFIException` if encoding fails.finalString blurHash = BlurhashFFI.encode(blurhashImageBytes);
// Or via codecfinalString blurHashSame = BlurhashFfiCodec().encoder.convert(blurhashImageBytes);
Decoding
Decoding now uses sync interface (without Future).
import'package:dart_blurhash_ffi/dart_blurhash_ffi.dart';
finalString blurhash = 'LGFO~6Yk^6#M@-5c,1Ex@@or[j6o';
/// Signature////// static Uint8List decode(/// String blurhash, {/// int width = 32,/// int height = 32,/// int punch = 1,/// })/// may throw `BlurhashFFIException` if decoding fails.final decoded = BlurhashFFI.decode(blurhash);
// or via codecfinalString decodedSame = BlurhashFfiCodec().decoder.convert(blurhash);