搜尋套件、儲存庫與 APP 分類

套件詳情v1.0.3

gif_view

載入 GIF 圖像並可設定幀率

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
2.2萬
喜歡數
79
Pub 分數
150

安裝套件

flutter pub add gif_view

套件介紹

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

gif_view 是一個 Flutter 套件,可讓應用程式載入並顯示 GIF 圖像,並支援自訂幀率。它提供一個簡單的 widget,可在多個平台(包括 Android、iOS、Web、macOS、Windows 和 Linux)上整合動畫 GIF。此套件能有效處理 GIF 的解碼與渲染,讓開發者可控制播放速度並管理動畫效能。非常適合需要動畫視覺效果但無需複雜設定的應用程式。該套件為開源,由 Rafael Barbosa 維護。

適用情境

  • 顯示動畫頭像
  • 載入帶有 GIF 的啟動畫面
  • 使用動畫創建互動式UI元素
  • 顯示載入指示器為 GIF 格式
  • 在教育類應用程式中整合動畫內容

主要特色

  • 支援自定幀率控制
  • 跨平台相容性
  • 簡單小工具整合
  • 高效的 GIF 解碼
  • 開源且持續維護

適合對象

  • 開發跨平台應用的開發者
  • 需要輕量級動畫圖形的應用
  • UI設計師將GIF整合到介面中
  • 帶有視覺內容的教育或娛樂應用

使用建議

  • 可能影響低端裝置的效能
  • 大型 GIF 檔案會增加記憶體使用
  • 超出幀率的進階動畫控制有限
  • 需要仔細優化以實現流暢播放

原始 README

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

pub package

GifView

Load GIF|APNG images and can set framerate

Features

With GifView you can load GIF images of easy way and can configure frameRate.

  • Load from Assets;
  • Load from Network;
  • Load from Memory;
  • Set frame rate;
  • Set progress while loading GIF

Getting started

Add gif_view as a dependency in your pubspec.yaml file.

Usage

GIF from Asset
  GifView.asset(
    'assets/gif1.gif',
    height: 200,
    width: 200,
    frameRate: 30, 
  )
GIF from Network
  GifView.network(
    'https://www.showmetech.com.br/wp-content/uploads/2015/09/happy-minion-gif.gif',
    height: 200,
    width: 200,
  )
GIF from Memory
  GifView.memory(
    _bytes,
    height: 200,
    width: 200,
  )

Atributes

Name Description Default
controller - -
frameRate - -
height - -
width - -
fit - -
color - -
colorBlendMode - -
alignment - Alignment.center
imageRepeat - ImageRepeat.noRepeat
centerSlice - -
matchTextDirection - false
invertColors - false
filterQuality - FilterQuality.low
isAntiAlias - false
onFinish - -
onStart - -
onFrame - -
onLoaded - -
loop - -
playInverted - -
errorBuilder You can return a widget to show when happen error -
progressBuilder You can return a widget to show while loading -
scale - 1.0
headers - -

Controller


  GifController controller = GifController();

  controller.play({bool? inverted, int? initialFrame});

  controller.pause();

  controller.stop();

  controller.seek(34);

  GifStatus status = controller.status;
  // GifStatus { loading, playing, stoped, paused, reversing }

Controller use simple example


class MyPage extends StatelessWidget {
  final controller = GifController();
  MyPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: GifView.network(
        'https://www.showmetech.com.br/wp-content/uploads/2015/09/happy-minion-gif.gif',
        controller: controller,
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          if (controller.status == GifStatus.playing) {
            controller.pause();
          } else {
            controller.play();
          }
        },
      ),
    );
  }
}


Cache Management

Pre-fetching Images

GifView provides a static preFetch method to load and cache GIF images ahead of time for better performance:

// Pre-fetch single or multiple GIFs
// Asset
await GifView.preFetch(AssetImage('my/path/item.gif'));
// Network
await GifView.preFetch(NetworkImage('http://my/path/item.gif'));
// Memory
await GifView.preFetch(MemoryImage(Uint8List()));
// File
await GifView.preFetch(FileImage(File()));
Custom Cache Provider

You can implement your own caching strategy by setting a custom cache provider:

// Create custom provider
class MyCustomCacheProvider implements GifCacheProvider {
  @override
  Future<void> add(String key, Uint8List bytes) async {
    // Custom cache implementation
  }

  @override
  Future<Uint8List?> get(String key) async {
    // Custom retrieval implementation
  }

  @override
  Future<void> clear() async {
    // Custom clear implementation
  }
}

// Set custom provider
GifView.setCacheProvider(MyCustomCacheProvider());

// Revert to default provider
GifView.setCacheProvider(null);

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。