搜索插件、代码仓与 APP 分类

sprung 封面
插件详情v3.0.1

sprung

适用于Flutter动画的弹簧曲线。基于真实的物理方程,包含三种阻尼曲线。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
4.8万
喜欢数
288
Pub 分数
160

安装插件

flutter pub add sprung

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Sprung 是一个 Flutter 包,提供基于物理的弹簧曲线,用于实现平滑、逼真的动画。受现实世界物理启发,它实现了三种阻尼曲线来模拟自然运动。非常适合用于按钮、滑块和过渡等交互式 UI 元素,Sprung 通过拟真响应性提升用户体验。该包可无缝集成到 Flutter 项目中,并支持所有主要平台,包括移动设备、网页和桌面端。专为希望精确控制动画动态而无需复杂手动计算的开发者设计。

适合场景

  • 交互式按钮反馈
  • 平滑滑动面板
  • 动画用户界面转换
  • 响应式表单元素
  • 动态小部件缩放
  • 自然滚动行为

主要特点

  • 基于物理的弹簧曲线
  • 三种阻尼曲线选项
  • 真实的运动模拟
  • 跨平台支持
  • 与 TweenAnimationBuilder 的轻松集成
  • 所需配置最少

适合对象

  • 寻求真实感的UI设计师
  • 开发交互式应用的开发者
  • 需要自然弹跳的动画
  • 面向多个平台的项目
  • 注重性能和流畅性的团队

使用建议

  • 可能需要针对特定用例进行调整
  • 最适合微妙、响应式的动画
  • 不适合高度复杂或自定义的物理效果
  • 限制为弹簧式插值
  • 在复杂的动画链中产生的性能影响

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

sprung

Sprung is an easy-to-consume Curve that uses real physics equations to drive your animations.

Easy to consume

Sprung has three opinionated curves, Sprung.underDamped, Sprung.criticallyDamped, and Sprung.overDamped. This is the best way to get started.

AnimatedContainer(
  curve: Sprung.underDamped,
  /// ...
),

When you want more fine control, use the default constructor which is critically damped, with overridable damping value.

AnimatedContainer(
  /// Critically damped by default with a value of `20`
  curve: Sprung(),
  /// ...
),
AnimatedContainer(
  /// Easily adjust damping value.
  curve: Sprung(19),
  /// ...
),

To build a fully custom spring simulation, use Sprung.custom. This allows you to define the spring's damping and stiffness, as well as the mass' mass and initial velocity.

AnimatedContainer(
  /// Build a custom spring
  curve: Sprung.custom(
    damping: 20,
    stiffness: 180,
    mass: 1.0,
    velocity: 0.0,
  ),
  /// ...
),

Based on Physics

Using Flutter's physics engine which leverages Newton's Second Law of Motion, Hooke's Law, and velocity based damping, we implement the following equation to create realistic spring animations.

m times x dot dot equals negative k times parenthesis x minus 1 close parenthesis minus c times x dot

Believable motion

demo of under, critically, and over damped Flutter curves

Reliable accuracy

Sprung exceeds Flutter specifications for curves by guaranteeing an error less than 1e-6. This amounts to a 0.0019px jitter at the beginning or end of a 1920px move.

所属分类

源码仓库

使用此插件的项目

所在榜单