搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目

暂无相关数据。