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

flutter_swiper_view 표지
패키지 상세v1.1.8

flutter_swiper_view

플러터용 최고의 스와이퍼(카루셀), 다양한 레이아웃과 무한 루프 지원. 안드로이드 및 iOS와 호환됩니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
5.9천
좋아요
130
Pub 점수
150

패키지 설치

flutter pub add flutter_swiper_view

패키지 개요

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

flutter_swiper_view는 높은 성능을 제공하는 플러터용 카루셀 위젯으로, 다양한 레이아웃 옵션과 무한 반복 기능을 제공합니다. 안드로이드, iOS, 웹, macOS, Windows, 리눅스에서 부드럽고 반응성 있는 스와이프 경험을 위해 설계되었으며, 사용자 정의 애니메이션을 지원하는 수평 및 수직 스크롤을 모두 지원합니다. 이미지 갤러리, 제품 전시, 인터랙티브 콘텐츠 슬라이더에 적합하며, 동적 UI를 위한 유연한 기반을 제공합니다. 이 패키지는 지속적으로 유지 관리되며 모든 주요 플랫폼과 호환됩니다.

사용 사례

  • 이미지 갤러리
  • 제품 캐러셀
  • 온보딩 화면
  • 인터랙티브 콘텐츠 슬라이더
  • 슬라이드 기반 탐색

주요 기능

  • 다양한 레이아웃 유형
  • 무한 루프 지원
  • 크로스 플랫폼 호환성
  • 사용자 지정 애니메이션
  • 부드러운 스와이프 제스처
  • 반응형 디자인

적합한 대상

  • 인터랙티브 UI를 구축하는 개발자
  • 시각 콘텐츠 카루셀이 필요한 앱
  • 다중 플랫폼 모바일 및 데스크톱 앱
  • 온보딩 경험
  • 전자상거래 제품 전시

고려 사항

  • 대규모 데이터 세트에 대한 성능 튜닝이 필요할 수 있습니다
  • 제한된 내장 페이지네이션 컨트롤
  • 고급 디자인을 위한 맞춤 스타일 필요
  • 매우 높은 빈도의 업데이트에 최적화되지 않음

원본 README

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

Logo

Build Status Coverage Status PRs Welcome pub package

中文说明

flutter_swiper_view

The best swiper for flutter , with multiple layouts, infinite loop. Compatible with Android & iOS.

:sparkles::sparkles: New Features:PageTransformer

Finally, we have PageTransformer like android, just set a transformer to Swiper, it returns a widget that has been transformed. For now, only support for layout DEFAULT. Thanks to @FlutterRocks ,you've done great job 👏.

:sparkles::sparkles: New Features:Layout

See More

Showcases

Horizontal

Vertical

Custom Pagination

Custom Pagination

Phone

Example

See More

Changelogs

see:CHANGELOG.md

Getting Started

Installation

Add

dependencies:
  flutter_swiper_view: ^1.1.8

to your pubspec.yaml ,and run

flutter pub get 

in your project's root directory.

Basic Usage

Create a new project with command

flutter create myapp

Edit lib/main.dart like this:

import 'package:flutter/material.dart';

import 'package:flutter_swiper_view/flutter_swiper_view.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Swiper(
        itemBuilder: (context, index){
          return Image.network("https://via.placeholder.com/350x150",fit: BoxFit.fill,);
        },
        itemCount: 3,
        pagination: const SwiperPagination(),
        control: const SwiperControl(),
      ),
    );
  }
}
Constructor
Basic
Parameter Default Description
scrollDirection Axis.horizontal If Axis.horizontal, the scroll view's children are arranged horizontally in a row instead of vertically in a column.
loop true Set to false to disable continuous loop mode.
index 0 Index number of initial slide.
autoplay false Set to true enable auto play mode.
onIndexChanged void onIndexChanged(int index) Called with the new index when the user swiped or autoplay
onTap void onTap(int index) Called when user tap ui.
duration 300.0 The milliscends of every transaction animation costs
pagination null set SwiperPagination() to show default pagination
control null set SwiperControl() to show default control buttons
Pagination

The pagination extends from SwiperPlugin,the SwiperPlugin provides extra ui for Swiper.Set SwiperPagination() to show default pagination.

Parameter Default Description
alignment Alignment.bottomCenter Change this value if you what to put pagination in other place
margin const EdgeInsets.all(10.0) The distance between inner side of the parent container.
builder SwiperPagination.dots There are three default styles SwiperPagination.dots and SwiperPagination.fraction、 SwiperPagination.rect,both can be customized.

If you'd like to customize your own pagination, you can do like this:

Swiper(
  ...,
  pagination: SwiperCustomPagination(
    builder: (context, config){
      return YourOwnPaginatipon();
    },
  )
);
Control buttons

The control also extends from SwiperPlugin,set SwiperControl() to show default control buttons.

Parameter Default Description
iconPrevious Icons.arrow_back_ios The icon data to display previous control button
iconNext Icons.arrow_forward_ios The icon data to display next.
color Theme.of(context).primaryColor Control button color
size 30.0 Control button size
padding const EdgeInsets.all(5.0) Control button padding
Controller

The Controller is used to control the index of the Swiper, start or stop autoplay.You can create a controller by SwiperController() and save the instance by futher usage.

Method Description
void move(int index, {bool animation: true}) Move to the spicified index,with animation or not
void next({bool animation: true}) Move to next
void previous({bool animation: true}) Move to previous
void startAutoplay() Start autoplay
void stopAutoplay() Stop autoplay
Autoplay
Parameter Default Description
autoplayDelay 3000 Autoplay delay milliseconds.
autoplayDisableOnInteraction true If set true, autoplay is disabled when use swipes.

Build in layouts

Swiper(
  itemBuilder: (context, index) {
    return Image.network(
      "https://via.placeholder.com/288x188",
      fit: BoxFit.fill,
    );
  },
  itemCount: 10,
  viewportFraction: 0.8,
  scale: 0.9,
)

Swiper(
  itemBuilder: (context, index) {
    return Image.network(
      "https://via.placeholder.com/288x188",
      fit: BoxFit.fill,
    );
  },
  itemCount: 10,
  itemWidth: 300.0,
  layout: SwiperLayout.STACK,
)

Swiper(
  itemBuilder: (context, index) {
    return Image.network(
      "https://via.placeholder.com/288x188",
      fit: BoxFit.fill,
    );
  },
  itemCount: 10,
  itemWidth: 300.0,
  itemHeight: 400.0,
  layout: SwiperLayout.TINDER,
)

Very easy to create you own custom animation:

Swiper(
  layout: SwiperLayout.CUSTOM,
  customLayoutOption: CustomLayoutOption(startIndex: -1, stateCount: 3)
    ..addRotate([-45.0 / 180, 0.0, 45.0 / 180])
    ..addTranslate([
      const Offset(-370.0, -40.0),
      const Offset(0.0, 0.0),
      const Offset(370.0, -40.0)
    ]),
  itemWidth: 300.0,
  itemHeight: 200.0,
  itemBuilder: (context, index) {
    return Container(
      color: Colors.grey,
      child: Center(
        child: Text("$index"),
      ),
    );
  },
  itemCount: 10,
),

The CustomLayoutOption is designed to describe animations. It is very easy to specify every state of items in Swiper.

CustomLayoutOption(
      startIndex: -1,  /// Which index is the first item of array below      
      stateCount: 3    /// array length 
  )..addRotate([        // rotation of every item 
    -45.0/180,
    0.0,
    45.0/180
  ])..addTranslate([           /// offset of every item
    const Offset(-370.0, -40.0),
    const Offset(0.0, 0.0),
    const Offset(370.0, -40.0)
  ])

Codes

Example

ConstrainedBox(
  constraints: BoxConstraints.loose(Size(screenWidth, 170.0))
  child: Swiper(
    outer: false,
    itemBuilder: (c, i) {
      return Wrap(
        runSpacing:  6.0,
        children: [0,1,2,3,4,5,6,7,8,9].map((i){
          return SizedBox(
            width: MediaQuery.of(context).size.width/5,
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                SizedBox(
                  height: MediaQuery.of(context).size.width * 0.12,
                  width: MediaQuery.of(context).size.width * 0.12,
                  child:  Image.network("https://fuss10.elemecdn.com/c/db/d20d49e5029281b9b73db1c5ec6f9jpeg.jpeg%3FimageMogr/format/webp/thumbnail/!90x90r/gravity/Center/crop/90x90"),
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 6.0),
                  child: Text("$i"),
                )
              ],
            ),
          );
        }).toList(),
      );
    },
    pagination: const SwiperPagination(margin: EdgeInsets.all(5.0)),
    itemCount: 10,
  ),
),

You can find all custom options here:

https://github.com/feicien/flutter_swiper_view/blob/master/example/lib/src/example_custom.dart

카테고리

소스 저장소

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