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

套件詳情v2.3.0

gif

使用 Flutter 動畫控制器控制 GIF。您可以指定固定持續時間,或設定播放幀率。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
4.1萬
喜歡數
80
Pub 分數
150

安裝套件

flutter pub add gif

套件介紹

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

gif 套件允許使用 AnimationController 在 Flutter 中精確控制 GIF 動畫。它支援固定時長播放與可自訂的幀率,讓開發者能將 GIF 與動畫或使用者互動同步。此套件相容於所有主要平台,包含行動裝置、網頁與桌面端,非常適合需要動態內容的 UI 元素。它簡化了將 GIF 整合至 Flutter 應用程式的過程,無需撰寫原生平台程式碼。

適用情境

  • 將 GIF 與動畫時間軸同步
  • 建立互動式動畫 UI 元件
  • 顯示動畫橫幅或載入指示器
  • 在跨平台應用程式中整合GIF
  • 動態控制播放速度

主要特色

  • AnimationController 結合
  • 支援固定時長或幀率
  • 跨平台相容性
  • 播放控制的簡單 API
  • 所有平台上的高效渲染

適合對象

  • 開發動畫使用者介面的開發者
  • 需要動態 GIF 播放的應用程式
  • 具有多媒體需求的跨平台專案
  • 帶有視覺反饋的互動式應用組件

使用建議

  • 可能影響大型 GIF 的效能
  • 長時間運行的動畫需要仔細的記憶體管理
  • 僅限靜態GIF(不支援具有複雜轉換的動畫GIF)
  • 最適合輕量級動畫
  • 未針對高幀率或影片類內容進行優化

原始 README

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

gif

Overview

We should know that in order to achieve Gif in flutter, we can use Image, but we have no way to manipulate Gif, for example: change its speed, control it has been playing in a frame, in which frame range loop. These problems can be solved by this widget, it also help you contain gif cache, avoid load frame every time.

Example

Load a gif asynchronously and display a text placeholder during loading.
When the gif is loaded reset the controller and run the gif to the end.

GifController _controller = GifController(vsync: this);

Gif(
    image: AssetImage("images/animate.gif"),
    controller: _controller, // if duration and fps is null, original gif fps will be used.
    //fps: 30,               
    //duration: const Duration(seconds: 3),
    autostart: Autostart.no,
    placeholder: (context) => const Text('Loading...'),
    onFetchCompleted: () {
         _controller.reset();
         _controller.forward();
    },
),

Thanks

License

MIT License

Copyright (c) 2019 Jpeng

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。