搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目

暂无相关数据。