搜尋套件、儲存庫與 APP 分類

draggable_carousel_slider 封面
套件詳情v0.0.1

draggable_carousel_slider

一個可拖曳的輪播圖滑塊組件,支援循環播放與自訂子組件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
42
喜歡數
25
Pub 分數
140

安裝套件

flutter pub add draggable_carousel_slider

套件介紹

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

一個 Flutter 小部件,提供可拖曳的輪播滑塊,支援循環與自訂子元件。它能實現流暢的水平捲動與直覺的拖曳手勢,非常適合以視覺上吸引人的方法顯示圖片、卡片或任何自訂內容。此滑塊支援無限循環,適用於連續內容展示。相容所有主要平台,包含 Android、iOS、Web、macOS、Windows 與 Linux,確保各處行為一致。非常適合需要互動式、可滑動內容顯示的應用程式。

適用情境

  • 顯示圖像畫廊
  • 創建產品輪播
  • 建構互動式入門畫面
  • 展示精選內容
  • 實現可滑動的卡片介面

主要特色

  • 可拖曳手勢支援
  • 循環模式
  • 可自定義的子部件
  • 跨平台相容性
  • 流暢的動畫
  • 響應式設計

適合對象

  • 行動應用開發者
  • Web應用程式創建者
  • 互動式UI設計師
  • 電子商務應用建構工具
  • 內容豐富的應用程式

使用建議

  • 需要仔細處理大型數據集
  • 可能影響效能,特別是當有大量子組件時
  • 需要在所有目標平台上進行測試
  • 內建樣式選項有限
  • 未針對垂直捲動進行優化

原始 README

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

Draggable Carousel Slider

Draggable Carousel Slider is a Flutter package that provides a customizable carousel slider widget with draggable functionality. It allows users to easily create interactive carousel sliders where items can be dragged.

Features

  • Draggable functionality: Items in the carousel slider can be dragged horizontally, providing an interactive user experience.
  • Looping option: The carousel slider supports looping through items, allowing seamless navigation from the last item back to the first.
  • Responsive design: The package includes features for handling various screen sizes and orientations, ensuring a consistent user experience across different devices.
  • Custom child widget: Users can supply their own custom widgets as carousel items, enabling a wide range of design possibilities.

Getting started

To start using the Draggable Carousel Slider package, you can simply add the package to your pubspec.yaml file and import it into your Flutter project.

dependencies:
  ...
  draggable_carousel_slider:

Usage

import 'package:draggable_carousel_slider/draggable_carousel_slider.dart';
import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});
  @override
  State<MyApp> createState() => _MyAppPageState();
}

class _MyAppPageState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  Widget _image(
    String path,
    double width,
    double height, [
    bool shimmer = false,
  ]) =>
      ClipRRect(
        borderRadius: BorderRadius.circular(16),
        child: Image.network(
          path,
          width: width,
          height: height,
          fit: BoxFit.cover,
          loadingBuilder: (
            BuildContext context,
            Widget child,
            ImageChunkEvent? loadingProgress,
          ) => AnimatedCrossFade(
              firstChild: child,
              secondChild: Shimmer.fromColors(
                baseColor: Colors.grey.shade400,
                highlightColor: Colors.grey.shade700,
                enabled: true,
                period: const Duration(seconds: 2),
                child: Container(
                  width: width,
                  height: height,
                  color: Colors.black,
                ),
              ),
              crossFadeState: shimmer ||
                      ((child as Semantics).child as RawImage).image == null
                  ? CrossFadeState.showSecond
                  : CrossFadeState.showFirst,
              duration: const Duration(milliseconds: 300),
            ),
        ),
      );

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.deepPurple,
        ),
        useMaterial3: true,
      ),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: SafeArea(
          child: Padding(
            padding: const EdgeInsets.symmetric(vertical: 16.0),
            child: Center(
              child: DraggableSlider(
                loop: true,
                children: [
                  _image('https://picsum.photos/id/230/600/600', 300, 300),
                  _image(
                      'https://picsum.photos/id/431/600/600', 300, 300, true),
                  _image('https://picsum.photos/id/232/600/600', 300, 300),
                  _image('https://picsum.photos/id/433/600/600', 300, 300),
                  _image('https://picsum.photos/id/234/600/600', 300, 300),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。