搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目

暂无相关数据。