搜索分类、插件与代码仓

插件详情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 项

源码仓库

使用此插件的项目

暂无相关数据。