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

sprung 封面
套件詳情v3.0.1

sprung

適用於Flutter動畫的彈簧曲線。基於真實的物理方程式,包含三種阻尼曲線。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
4.3萬
喜歡數
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.

所屬分類

原始碼儲存庫

使用此套件的專案

所在榜單