搜尋分類、套件與程式碼儲存庫

flutter_carousel_slider 封面
套件詳情v1.1.0

flutter_carousel_slider

一個可自定義的 Flutter 輪播圖滑塊。支援無限滑動、自訂指示器和自訂動畫,並提供多種預建指示器和動畫。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
4060
喜歡數
180
Pub 分數
140

安裝套件

flutter pub add flutter_carousel_slider

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個高度可自訂的輪播滑塊,適用於 Flutter,支援在項目之間實現流暢、無限滑動。它支援自訂指示器和動畫,提供一系列預建選項,用於視覺指示器和過渡效果。非常適合在多個平台以動態、互動方式展示圖片、產品或內容。該套件輕量且能輕鬆整合至 Flutter 應用中,設定簡單。

適用情境

  • 展示產品圖片
  • 顯示促銷橫幅
  • 展示用戶評價
  • 建立影像相簿
  • 突出顯示應用功能

主要特色

  • 無限滾動
  • 可自定指標
  • 預建構的動畫選項
  • 對多個平台的支援
  • 可擴展的設計
  • 平滑過渡

適合對象

  • 電子商務應用
  • 行銷網站
  • 投資組合顯示
  • 內容豐富的移動應用
  • 互動式介面

使用建議

  • 大型數據集的性能
  • 自定指標複雜度
  • 低端設備上的動畫延遲
  • 有限的內建滑動手勢
  • 需要手動處理點擊事件

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Flutter Carousel Slider

A customizable carousel slider for flutter

pub package

Screenshots

Installing

dependencies:
  flutter_carousel_slider: ^1.1.0

Demo

Demo application available at https://flutter-carousel-slider.web.app/

Using

import 'package:flutter/material.dart';
import 'package:flutter_carousel_slider/carousel_slider.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Carousel Slider',
      home: MyHomePage(title: 'Flutter Carousel Slider'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  final String title;

  MyHomePage({Key key, this.title}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final List<Color> colors = [
    Colors.red,
    Colors.orange,
    Colors.yellow,
    Colors.green,
    Colors.blue,
    Colors.indigo,
    Colors.purple,
  ];
  final List<String> letters = [
    "A",
    "B",
    "C",
    "D",
    "E",
    "F",
    "G",
  ];

  bool _isPlaying = false;
  GlobalKey<CarouselSliderState> _sliderKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: ListView(
        children: <Widget>[
          Container(
            height: 500,
            child: CarouselSlider.builder(
                key: _sliderKey,
                unlimitedMode: true,
                slideBuilder: (index) {
                  return Container(
                    alignment: Alignment.center,
                    color: colors[index],
                    child: Text(
                      letters[index],
                      style: TextStyle(fontSize: 200, color: Colors.white),
                    ),
                  );
                },
                slideTransform: CubeTransform(),
                slideIndicator: CircularSlideIndicator(
                  padding: EdgeInsets.only(bottom: 32),
                ),
                itemCount: colors.length),
          ),
          Padding(
            padding: const EdgeInsets.symmetric(vertical: 32),
            child: Align(
              child: ConstrainedBox(
                constraints: BoxConstraints(minWidth: 240, maxWidth: 600),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  children: [
                    IconButton(
                      iconSize: 48,
                      icon: Icon(Icons.skip_previous),
                      onPressed: () {
                        _sliderKey.currentState.previousPage();
                      },
                    ),
                    IconButton(
                      iconSize: 64,
                      icon: Icon(
                        _isPlaying
                            ? Icons.pause_circle_outline
                            : Icons.play_circle_outline,
                      ),
                      onPressed: () {
                        setState(
                          () {
                            _isPlaying = !_isPlaying;
                            _sliderKey.currentState.setPlaying(_isPlaying);
                          },
                        );
                      },
                    ),
                    IconButton(
                      iconSize: 48,
                      icon: Icon(Icons.skip_next),
                      onPressed: () {
                        _sliderKey.currentState.nextPage();
                      },
                    ),
                  ],
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}

所屬分類

原始碼儲存庫

使用此套件的專案