搜尋分類、套件與程式碼儲存庫

套件詳情v0.1.0+1

flutter_custom_carousel

用於建立完全自訂、可動畫滾動清單的組件。它會處理所有複雜的捲動邏輯,而視覺呈現則交由您決定。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
11
喜歡數
345
Pub 分數
150

安裝套件

flutter pub add flutter_custom_carousel

套件介紹

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

一個靈活的 Flutter 小部件,用於建立完全可自訂、帶動畫效果的可捲動清單。它處理複雜的捲動邏輯——例如吸附點和動量——同時允許對視覺設計進行完全控制。非常適合建立獨特的幻燈片輪播、封面流或具有平滑動畫的自訂滑動介面。開發者可以定義自己的項目佈局和過渡效果,而不受預設範本的限制。

適用情境

  • 創建互動式產品滑塊
  • 構建動畫封面流介面
  • 設計自定義滑動內容畫廊
  • 使用動態視覺效果實現入門畫面
  • 開發響應式圖像或卡片輪播

主要特色

  • 完全可自訂的項目小部件
  • 內建的動畫和吸附邏輯
  • 支援所有主要平台
  • 輕量且高效
  • 與現有 Flutter 專案的輕鬆整合
  • 可擴展以支援自訂手勢

適合對象

  • 尋求創意自由的UI設計師
  • 開發互動式應用元件的開發者
  • 需要獨特滾動行為的專案
  • 具有豐富媒體內容的應用程式顯示
  • 希望獲得可重複使用的輪播解決方案的團隊

使用建議

  • 每個項目都需要手動佈局設計
  • 性能取決於項目複雜度
  • 內建樣式選項有限
  • 可能需要額外的狀態管理來處理高級互動
  • 不適合簡單的靜態清單

原始 README

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

Flutter Custom Carousel

A widget for creating fully custom, animated scrollable lists. It manages all of the tricky logic surrounding scroll interactions and physics, and leaves the visual presentation of items up to you.

Includes an example app (shown above) with a variety of commented demos to learn from or customize.

Platforms / devices

Currently, this widget is designed for touch input. On desktop, scroll wheel input can fight with the settling scroll physics. Specifying different physics can resolve this at the cost of settling (aka snapping).

You can also enable scrolling via mouse dragging on desktop by setting a scrollBehavior. Check main.dart in the example to see it in use.

Similarly, the included examples target mobile handsets in portrait view to keep them concise. They include only basic responsiveness.

Basics

Simply pass in a list of children, and define an effectsBuilder function.

effectsBuilder accepts a child and its current relative scroll position (see scrollRatio below), and returns the child wrapped with widgets that apply the desired effects.

// very basic example that scrolls children vertically from -250px to +250px
CustomCarousel(
    children: [card1, card2, etc],
    effectsBuilder: (index, scrollRatio, child) =>
       Transform.translate(
            offset: Offset(0, scrollRatio * 250) ,
            child: child
       ),
)

You can further refine visuals by specifying how many children to display before and after the selection, whether to loop the list, a default alignment, and how to depth sort children.

Adjust interactions by changing the scroll direction, physics, & speed, enabling tap to select, or specifying handlers for when the selected item changes, or when it settles into position.

scrollRatio

The scrollRatio value ranges from -1 to +1, where 0 is the settled position of the selected item.

The following animation displays the scrollRatio for each item as it scrolls. It also highlights the "selected" item (white background), and the "settled" item (thick outline).

Try watching a single item at a time to see how the ratio relates to selection, settling, and items entering / exiting the visible list. Note that the specific values are dependent on factors like itemsBefore / itemsAfter.

ScrollControllers and ScrollPhysics

To facilitate item-oriented navigation and looping content CustomCarousel requires that you use CustomCarouselScrollController. This controller also provides useful features such as jumpToItem, animateToItem, nextItem, and previousItem, as well as smart defaults for animation durations and curves.

Similarly, CustomCarousel defaults to CustomCarouselScrollPhysics, which enables "settling" onto selected items (aka snapping). Adjust the behavior of the physics by setting the sticky and stiffness properties. You can use other scroll physics (such as BouncingScrollPhysics) if you don't want this functionality.

Using with Flutter Animate

You can also use Flutter Animate to define the effectsBuilder, leveraging it's broad collection of effects, such as fading, moving, blurs, shadows, shimmers, color effects, 2.5d flips, and more.

For example, the simple vertical scroller from above would look like this:

// very basic example that scrolls children vertically from -250px to +250px
CustomCarousel(
    children: [card1, card2, etc],
    effectsBuilder: CustomCarousel.effectsBuilderFromAnimate(
        effects: EffectList().moveY(begin: -250, end: 250),
    ),
)

A number of the included examples demonstrate this approach in more depth. See the docs for CustomCarousel.effectsBuilderFromAnimate() for more info.

API reference

For full documentation, see the API reference.

Installation

Grab it from pub.dev.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。