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

套件詳情v0.5.3

follow_the_leader

跟隨其他組件的小部件。

AndroidiOS
近 30 天下載
4萬
喜歡數
37
Pub 分數
150

安裝套件

flutter pub add follow_the_leader

套件介紹

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

一個 Flutter 套件,讓組件能動態追蹤螢幕上其他組件的位置。非常適合建立互動式 UI 元件,例如工具提示、浮動指標或追蹤目標組件移動的動畫覆蓋層。此套件以效能與簡易性為設計核心,可在 Android 與 iOS 平台順暢運作。該套件有效利用 Flutter 的渲染流程,確保流暢動畫且無卡頓。適合希望藉由回應式視覺反饋提升使用者體驗的開發者。

適用情境

  • 建立動態提示
  • 構建追蹤內容的浮動操作按鈕
  • 設計動畫疊加層
  • 實施引導式遊覽
  • 可視化光標或選擇路徑

主要特色

  • 即時小工具追蹤
  • 平滑的動畫整合
  • 跨平台相容性
  • 最小化樣板程式碼
  • 高效渲染,開銷最小

適合對象

  • 尋求互動元件的UI/UX設計師
  • 開發人員建構引導式入門流程
  • 需要動態視覺反饋的應用程式
  • 專注於打造精緻移動體驗的團隊

使用建議

  • 追蹤大量 Widget 時可能影響效能
  • 需要仔細定位以避免重疊
  • 不適用於靜態版面
  • 需要在低階設備上進行測試
  • 最佳搭配輕量級目標組件使用

原始 README

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

Follow the Leader - Widgets following widgets

Built by the Flutter Bounty Hunters


Getting Started

Select a widget that you want to follow and wrap it with a Leader widget. Give the Leader widget a LeaderLink, to share with Followers.

Leader(
  link: _leaderLink,
  child: YourLeaderWidget(),
);

Add a widget that you want to follow your Leader, and wrap it with a Follower widget.

// Follower appears 20px above the Leader.
Follower.withOffset(
  link: _leaderLink,
  offset: const Offset(0, -20),
  leaderAnchor: Alignment.topCenter,
  followerAnchor: Alignment.bottomCenter,
  child: YourFollowerWidget(),
);

Follower's can position themselves with a constant distance from a Leader using .withOffset(), as shown above. Or, Follower's can choose their exact location on every frame by using .withAligner().

// Follower appears where the aligner says it should.
Follower.withAligner(
  link: _leaderLink,
  aligner: _aligner,
  child: YourFollowerWidget(),
);

To constrain where your Follower is allowed to appear, pass a boundary to your Follower.

// Follower is constrained by the given boundary.
Follower.withAligner(
  link: _leaderLink,
  aligner: _aligner,
  boundary: _boundary,
  child: YourFollowerWidget(),
);

Building multiple widgets without layouts

Building follower widgets is a bit unusual with Flutter. Typically, whenever we build multiple widgets in Flutter, we place them in a layout container, such as Column, Row, or Stack. But follower widgets don't respect ancestor layout rules. That's the whole point.

follow_the_leader introduces a new container widget, which builds children, but doesn't attempt to apply any particular layout rules. The primary purpose of this widget is to make it clear to readers that you aren't trying to layout the children.

BuildInOrder(
  children: [
    MyContentWithALeader(),
    Follower.withOffset(),
    Follower.withDynamics(),
  ],
);

The BuildInOrder widget builds each child widget in the order that it's provided. This fact is important because Leader widgets must be built before their Followers. But BuildInOrder does not impose any Offset on its children. BuildInOrder passes its parent's constraints down to the children.

所屬分類

依賴

依賴清單 3 項

原始碼儲存庫

使用此套件的專案