분류, 패키지 및 저장소 검색

carousel_slider_plus 표지
패키지 상세v7.1.2

carousel_slider_plus

무한 스크롤과 사용자 정의 자식 위젯을 지원하는 카루셀 슬라이더 위젯입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
4.3만
좋아요
97
Pub 점수
160

패키지 설치

flutter pub add carousel_slider_plus

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

무한 스크롤과 사용자 정의 자식 위젯을 지원하는 부드럽고 사용자 지정 가능한 카루셀 슬라이더를 만들기 위한 플러터 위젯입니다. 이미지, 카드 또는 어떤 콘텐츠든 시각적으로 매력적인 수평 또는 수직 스크롤 레이아웃에서 표시하기에 적합합니다. 이 패키지는 가볍고 모바일, 웹, 데스크톱을 포함한 여러 플랫폼 앱에 원활하게 통합됩니다. 개발자는 인디케이터, 자동 재생 및 스와이프 제스처를 쉽게 구성하여 사용자 경험을 향상시킬 수 있습니다.

사용 사례

  • 이미지 갤러리 표시
  • 제품 캐러셀 표시
  • 온보딩 화면 만들기
  • 주목할 만한 콘텐츠 소개
  • 인터랙티브 슬라이더 만들기
  • 프로모션 배너 강조

주요 기능

  • 무한 스크롤 지원
  • 사용자 지정 가능한 자식 위젯
  • 자동 재생 기능
  • 지표 사용자 정의
  • 크로스 플랫폼 호환성
  • 부드러운 애니메이션

적합한 대상

  • 모바일 앱 개발자
  • 웹 애플리케이션 제작자
  • 데스크톱 앱 통합자
  • UI/UX 디자이너
  • 전자상거래 애플리케이션
  • 온보딩 화면 구현

고려 사항

  • 대규모 데이터 세트에 대한 최적화가 필요할 수 있습니다
  • 제한된 내장 스타일링 옵션
  • 중량 자식 위젯으로 인한 성능 영향
  • 복잡한 중첩 레이아웃에 적합하지 않습니다
  • 터치 이벤트를 수동으로 처리해야 합니다
  • 고급 기능을 위해 외부 종속성에 의존합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

carousel_slider_plus

A carousel slider widget.

This package is fork of carousel_slider which is not actively maintained.

pub package

likes popularity pub points



Migrating from carousel_slider

In this fork some of the namings are changed. So follow this below guides to migrate over this new package.

Please make sure to change the import statement
Before
import "package:carousel_slider/carousel_slider.dart;
After
import 'package:carousel_slider_plus/carousel_slider_plus.dart';
The parameter name to pass controller in CarouselSlider is now changed to controller from carouselController.
Before
CarouselSlider(
  carouselController: _controller,
  // Rest of the code
),
After
CarouselSlider(
  controller: _controller,
  // Rest of the code
),

Features

  • Infinite scroll
  • Custom child widgets
  • Auto play

Live preview

https://kishan-dhankecha.github.io/carousel-slider-plus-gh-pages/

Note: this page is built with flutter-web. For a better user experience, please use a mobile device to open this link.

Installation

Add latest version of carousel_slider_plus to your pubspec.yaml dependencies. And import it:

import 'package:carousel_slider_plus/carousel_slider_plus.dart';

How to use

Simply create a CarouselSlider widget, and pass the required params:

CarouselSlider(
  options: CarouselOptions(height: 400.0),
  items: [1,2,3,4,5].map((i) {
    return Builder(
      builder: (BuildContext context) {
        return Container(
          width: MediaQuery.of(context).size.width,
          margin: EdgeInsets.symmetric(horizontal: 5.0),
          decoration: BoxDecoration(
            color: Colors.amber
          ),
          child: Text('text $i', style: TextStyle(fontSize: 16.0),)
        );
      },
    );
  }).toList(),
)
Parameters
CarouselSlider(
  items: items,
  options: CarouselOptions(
    height: 400,
    aspectRatio: 16/9,
    viewportFraction: 0.8,
    initialPage: 0,
    enableInfiniteScroll: true,
    reverse: false,
    autoPlay: true,
    autoPlayInterval: Duration(seconds: 3),
    autoPlayAnimationDuration: Duration(milliseconds: 800),
    autoPlayCurve: Curves.fastOutSlowIn,
    enlargeCenterPage: true,
    enlargeFactor: 0.3,
    onPageChanged: callbackFunction,
    scrollDirection: Axis.horizontal,
  )
)

If you pass the height parameter, the aspectRatio parameter will be ignored.

Build item widgets on demand

This method will save memory by building items once it becomes necessary. This way they won't be built if they're not currently meant to be visible on screen. It can be used to build different child item widgets related to content or by item index.

CarouselSlider.builder(
  itemCount: 15,
  itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) {
    return Container(
      child: Text(itemIndex.toString()),
    );
  }
)
Carousel controller

In order to manually control the PageView's position, you can create your own CarouselSliderController, and pass it to CarouselSlider. Then you can use the CarouselSliderController instance to manipulate the position.

class CarouselDemo extends StatelessWidget {
  CarouselSliderController buttonCarouselController = CarouselSliderController();

  @override
  Widget build(BuildContext context) => Column(
    children: <Widget>[
      CarouselSlider(
        items: child,
        controller: buttonCarouselController,
        options: CarouselOptions(
          autoPlay: false,
          enlargeCenterPage: true,
          viewportFraction: 0.9,
          aspectRatio: 2.0,
          initialPage: 2,
        ),
      ),
      RaisedButton(
        onPressed: () => buttonCarouselController.nextPage(
            duration: Duration(milliseconds: 300), curve: Curves.linear),
        child: Text('→'),
      )
    ]
  );
}
CarouselSliderController methods
/// Animate to the next page
controller.nextPage({Duration duration, Curve curve});


/// Animate to the previous page
controller.previousPage({Duration duration, Curve curve});


/// Jump to the given page.
controller.jumpToPage(int page);


/// Animate to the given page.
controller.animateToPage(int page, {Duration duration, Curve curve});


/// Start/Stop Auto-play (only work if `autoplay` is set to true in `CarouselOptions`)
controller.startAutoPlay();

Screenshots

Basic text carousel slider:

simple

Basic image carousel slider:

image

A more complicated image carousel slider:

complicated image

Full Screen image carousel slider:

fullscreen

Image carousel slider with custom indicator:

indicator

Manually control the page position:

manual

Vertical carousel slider:

vertical

Simple on-demand image carousel slider, with image auto prefetch:

prefetch

No infinite scroll:

no-loop

All screenshots above can be found at the example project.

License

MIT

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트