완전히 사용자 정의가 가능하고 애니메이션 효과를 갖춘 스크롤 가능한 목록을 만들기 위한 유연한 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 +250pxCustomCarousel(
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 +250pxCustomCarousel(
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.