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

套件詳情v1.0.3

infinite_cards

一個無限卡片切換的 Flutter UI,支援自訂動畫

近 30 天下載
19
喜歡數
31
Pub 分數
40

安裝套件

flutter pub add infinite_cards

套件介紹

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

一個 Flutter 套件,提供無限卡牌切換介面,支援順暢且可自訂的卡牌過渡效果。它支援自訂動畫,讓開發者能創造類似封面流或無窮卡牌滑動體驗的吸引人、互動式 UI。非常適合以視覺動態方式展示圖片、個人資料或產品清單等內容。此套件設計簡潔彈性,可透過 pub.dev 輕鬆整合。特別適用於需要沉浸式基於卡牌導航的應用。

適用情境

  • 互動式產品輪播
  • 資料瀏覽介面
  • 帶有滑動手勢的圖片畫廊
  • 動態內容滑塊
  • 使用者入門流程

主要特色

  • 無限卡循環
  • 可自訂的過渡動畫
  • 與 Flutter 的簡單整合
  • 支援橫向卡牌滑動
  • 可擴展的動畫控制

適合對象

  • 開發基於卡片的使用者介面的開發者
  • 需要吸引人內容導航的應用程式
  • 尋求互動式原型的設計師
  • 具有動態數據展示的項目
  • 具有視覺敘事的行動應用程式

使用建議

  • 可能需要對大型數據集進行性能優化
  • 自訂動畫需要小心處理,以避免卡頓
  • 有限的平台特定自定選項
  • 未針對垂直捲動進行優化
  • 依賴外部GitHub倉庫進行更新

原始 README

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

InfiniteCards

License pub package

An infinite card switching UI for Flutter, support custom animation 可自定义动效的卡片切换视图(中文文档)

Android version

https://github.com/BakerJQ/Android-InfiniteCards

Flutter for Web version

https://github.com/BakerJQ/Flutter-InfiniteCards/tree/web

Screenshot

Android iOS

Example

cd ./example
flutter create .
flutter run

How to use

Add dependencies
dependencies:
  infinite_cards: ^1.0.3
Build controller in initState
@override
  void initState() {
    super.initState();
    _controller = InfiniteCardsController(
      itemBuilder: _renderItem,
      itemCount: 5,
      animType: AnimType.SWITCH,
    );
  }
  • animType : animation type
    • TO_FRONT : move the selected card to first
    • SWITCH : move the selected card to first, and the first card to the selected position
    • TO_END : move the first card to last position
Build widget with controller
InfiniteCards(
  controller: _controller,
)
Call methods from controller
  _controller.previous();
  _controller.next();
  _controller.reset(...);
Animation transform and curve
Default

If you just use all default animations, just do nothing.

Customisation
InfiniteCardsController(
            ...
            transformToFront: yourCustomTransformToFront,
            transformToBack: yourCustomTransformToBack,
            curve: yourCustomCurve
            ...
          )

One example of implement Transform

Transform _defaultCommonTransform(Widget item, 
    double fraction, double curveFraction, double cardHeight, double cardWidth, int fromPosition, int toPosition) 
  {
  //Count of card which needs to move over
  int positionCount = fromPosition - toPosition;
  //0.8 scale for the first card, and -0.1 per card behind
  //(0.8 - 0.1 * fromPosition) = current specific card scale
  //(0.1 * fraction * positionCount) = scale while moving
  double scale = (0.8 - 0.1 * fromPosition) + (0.1 * fraction * positionCount);
  //translate -0.02 * cardHeight per card behind
  //-cardHeight * (0.8 - scale) * 0.5 to center the card
  double translationY = -cardHeight * (0.8 - scale) * 0.5 -
      cardHeight * (0.02 * fromPosition - 0.02 * fraction * positionCount);
  //return the Widget after scale and translate
  return Transform.translate(
    offset: Offset(0, translationY),
    child: Transform.scale(
      scale: scale,
      child: item,
    ),
  );
}

License

InfiniteCards is released under the Apache 2.0 license.

Copyright 2019 BakerJ.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at following link.

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。