搜尋分類、套件與程式碼儲存庫

image_blur 封面
套件詳情v1.1.0

image_blur

此 Flutter 套件可為影像加入閃爍與模糊效果。可將這些效果應用於圓形與矩形形狀,適用於本機與線上影像。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
125
喜歡數
23
Pub 分數
140

安裝套件

flutter pub add image_blur

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

image_blur 套件透過在影像上啟用閃爍與模糊效果來增強 Flutter 應用程式。它支援本機與線上影像,並可在圓形或矩形形狀中套用效果。非常適合建立動態佔位符或載入狀態,在影像載入期間改善使用者體驗。此套件輕量且相容於所有主要平台,包含 Android、iOS、Web、macOS、Windows 與 Linux。

適用情境

  • 載入狀態指示器
  • 圖像佔位符動畫
  • 增強的UI轉換效果
  • 圖像獲取過程中的視覺反饋
  • 互動式圖像組件
  • 平滑的內容加載

主要特色

  • 光澤效果支援
  • 模糊效果應用
  • 圓形和矩形形狀遮罩
  • 支援本機和遠端影像
  • 跨平台相容性
  • 簡單 API 結合

適合對象

  • 開發動態 UI 的開發者
  • 載入大量圖片的應用
  • 注重設計的應用程式
  • 原型設計互動介面
  • 創造引人入勝的加載體驗

使用建議

  • 多個效果帶來的效能影響
  • 除了形狀和強度之外,自訂功能有限
  • 可能需要額外的樣式才能實現複雜的佈局
  • 未針對非常大的圖像進行優化
  • 最佳搭配中等動畫頻率使用

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Image Blur

This Flutter package provides the ability to add shimmer and blur effects to your images. You can apply these effects in circular and rectangular shapes, and use them with both local and online images.

blur

Initialize the cache configuration

void main() async {
  await ImageBlur.init();
  runApp(const MyApp());
}

Features

1. ImageBlur - Progressive Blur Loading

Display images with a progressive blur effect that smoothly transitions as the image loads.

ImageBlur(
  imageUrl: "https://picsum.photos/id/10/400/300",
  width: 300,
  height: 200,
  fit: BoxFit.cover,
  borderRadius: BorderRadius.circular(12),
)

blur-4


2. ImageHashPreview - BlurHash Placeholder

Display a BlurHash preview while the actual image loads. Great for smooth loading experiences.

ImageBlur.imageHashPreview(
  imagePath: "https://picsum.photos/id/15/400/300",
  width: 300,
  height: 200,
  fit: BoxFit.cover,
  borderRadius: BorderRadius.circular(8),
  duration: const Duration(milliseconds: 1000),
)

blur-3


3. ImageHashPreviewCircular - Circular BlurHash

Circular version of BlurHash preview, perfect for avatars and profile pictures.

ImageBlur.imageHashPreviewCircular(
  size: 120,
  imagePath: "https://picsum.photos/id/22/200/200",
  fit: BoxFit.cover,
)

blur-1


4. ImageCircularBlur - Circular with Shimmer Effect

Circular image with shimmer and blur effects.

ImageBlur.imageCircularBlur(
  size: 120,
  imageNetwork: "https://picsum.photos/id/1/200/200",
  isShimmer: true,
  isBlur: true,
)

blur-2


5. OptimizedImageHashPreview - Fast & Cached BlurHash

Optimized version with caching support for better performance. NEW

ImageBlur.optimizedImageHashPreview(
  imagePath: "https://picsum.photos/id/20/400/300",
  width: 300,
  height: 200,
  fit: BoxFit.cover,
  borderRadius: BorderRadius.circular(8),
  duration: const Duration(milliseconds: 500),
  hashLoadDelay: const Duration(milliseconds: 100),
  imageShowDelay: const Duration(milliseconds: 300),
  onLoaded: () {
    debugPrint('Image loaded successfully');
  },
  errorBuilder: (context, error) {
    return const Center(child: Icon(Icons.error));
  },
)

6. ImageBlurGetPaletteColor - Extract Dominant Colors

Extract the dominant color palette from an image for dynamic theming.

ImageBlur.imageBlurGetPalletteColor(
  imageUrl: "https://picsum.photos/id/28/400/300",
  width: 300,
  height: 200,
  borderRadius: BorderRadius.circular(8),
  onPaletteReceived: (paletteFuture) async {
    final palette = await paletteFuture;
    if (palette != null && palette.dominantColor != null) {
      // Use the dominant color
      print('Dominant color: ${palette.dominantColor!.color}');
    }
    return null;
  },
)

20240505_073705


7. BlurIsWeb - Web-Optimized Blur

Optimized for web platforms with placeholder and thumbnail support.

ImageBlur.blurIsWeb(
  placeholder: const AssetImage("assets/placeholder.jpg"),
  thumbnail: const NetworkImage("https://picsum.photos/id/5/50/50"),
  image: const NetworkImage("https://picsum.photos/id/5/400/300"),
  width: 300,
  height: 200,
  fit: BoxFit.cover,
  blur: 20.0,
)

BlurHash Cache Management

Manage BlurHash caching for better performance:

// Clear all cached BlurHash values
ImageHashManager.clearCache();

// Set maximum cache size (default: 100)
ImageHashManager.setMaxCacheSize(200);

// Preload BlurHash for multiple images
await ImageHashManager.preloadHashes([
  "https://picsum.photos/id/1/200/300",
  "https://picsum.photos/id/2/200/300",
  "https://picsum.photos/id/3/200/300",
]);

Getting started

dependencies:
  image_blur: ^1.1.0

How to use

import 'package:image_blur/image_blur.dart';

Complete Example

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

void main() async {
  await ImageBlur.init(removeCacheTime: 30);
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Image Blur Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const ImageGallery(),
    );
  }
}

class ImageGallery extends StatelessWidget {
  const ImageGallery({super.key});

  // Sample image URLs
  static const List<String> imageUrls = [
    "https://picsum.photos/id/10/400/300",
    "https://picsum.photos/id/11/400/300",
    "https://picsum.photos/id/12/400/300",
    "https://picsum.photos/id/13/400/300",
    "https://picsum.photos/id/14/400/300",
    "https://picsum.photos/id/15/400/300",
    "https://picsum.photos/id/16/400/300",
    "https://picsum.photos/id/17/400/300",
    "https://picsum.photos/id/18/400/300",
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Image Blur Gallery'),
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      ),
      body: Padding(
        padding: const EdgeInsets.all(8.0),
        child: GridView.builder(
          itemCount: imageUrls.length,
          gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 3,
            crossAxisSpacing: 8,
            mainAxisSpacing: 8,
          ),
          itemBuilder: (context, index) {
            return ImageBlur.imageHashPreview(
              imagePath: imageUrls[index],
              fit: BoxFit.cover,
              borderRadius: BorderRadius.circular(12),
            );
          },
        ),
      ),
    );
  }
}

Additional information

If you have any issues, questions, or suggestions related to this package, please feel free to contact us at [swan.dev1993@gmail.com](mailto:zagros.development.group@gmail.com). We welcome your feedback and will do our best to address any problems or provide assistance.

For more information about this package, you can also visit our GitHub repository where you can find additional resources, contribute to the package's development, and file issues or bug reports. We appreciate your contributions and feedback, and we aim to make this package as useful as possible for our users.

Thank you for using our package, and we look forward to hearing from you!

所屬分類

依賴

依賴清單 8 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。