搜索插件、代码仓与 APP 分类

wheel_slider 封面
插件详情v1.2.2

wheel_slider

Wheel Slider 提供了大量自定义选项,可让你以类似轮子的外观进行滚动。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
6990
喜欢数
133
Pub 分数
150

安装插件

flutter pub add wheel_slider

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Wheel Slider 是一个可自定义的 Flutter 小部件,提供类似轮盘的界面,用于滚动选择数值,非常适合以视觉吸引人的方式选择数字或选项。它支持平滑旋转和丰富的样式选项,适用于表单、设置或交互式 UI。该组件可在所有主要平台上使用,并能轻松集成到 Flutter 应用中,设置简单。该包注重用户体验,支持响应式手势和动画过渡。

适合场景

  • 带数字选择的表单输入
  • 自定义数字选择器
  • 交互式应用设置
  • 游戏化用户界面元素
  • 时间或日期选择器
  • 视觉数据输入

主要特点

  • 高度可定制的外观
  • 平滑的滚轮旋转动画
  • 跨平台支持
  • 基于手势的滚动
  • 丰富的样式选项
  • 响应式触摸交互

适合对象

  • 寻求独特输入控件的开发者
  • 需要视觉数据输入的应用程序
  • 注重设计的 Flutter 项目
  • 交互式教育工具
  • 带有数值选择的游戏

使用建议

  • 在低端设备上可能需要性能调优
  • 除了基本用法外,文档有限
  • 自定义可能会增加代码复杂性
  • 不适合大型数据集
  • 需要仔细处理滚动灵敏度
  • 最适合小到中等数值范围

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Wheel Slider

A versatile and highly customizable slider widget for Flutter, with a wheel-like scrolling appearance.

pub package License: MIT

gif of wheel slider gif of wheel slider

Built on top of wheel_chooser for an enhanced experience.

✨ Features

  • 🔢 Number Display: Show numbers instead of simple lines.
  • ↔↕ Scroll Orientation: Horizontal and vertical scrolling options.
  • 📳 Haptic Feedback: Vibrates during scroll for a tactile experience.
  • 🔧 Custom Widgets: Fully customizable items and pointers.
  • 🖼️ Background Support: Add a widget as the slider's background.
  • 🎨 Styling Options: Easily customize line and pointer colors.

🚀 Getting Started

Installation

Add the following to your pubspec.yaml under dependencies:

  dependencies:
    wheel_slider:
Import
import 'package:wheel_slider/wheel_slider.dart';
Android Permissions

Add the vibration permission to your AndroidManifest.xml file:

<uses-permission android:name="android.permission.VIBRATE"/>
IOS Compatibility

Supports vibration with duration and pattern on CoreHaptics devices. On older devices, the pattern is emulated with 500ms long vibrations.

📖 Usage

To use Line Slider:

WheelSlider(
    totalCount: _totalCount,
    initValue: _initValue,
    onValueChanged: (val) {
        setState(() {
          _currentValue = val;
        });
    },
    hapticFeedbackType: HapticFeedbackType.vibrate,
),

To use Line Slider with displaying double value:

WheelSlider(
    interval: 0.5,  // this field is used to show decimal/double values
    totalCount: _totalCount,
    initValue: _initValue,
    onValueChanged: (val) {
        setState(() {
          _currentValue = val;
        });
    },
    hapticFeedbackType: HapticFeedbackType.vibrate,
),

To use Number Slider:

WheelSlider.number(
    perspective: 0.01,
    totalCount: _nTotalCount,
    initValue: _nInitValue,
    unSelectedNumberStyle: const TextStyle(
        fontSize: 12.0,
        color: Colors.black54,
    ),
    currentIndex: _nCurrentValue,
    onValueChanged: (val) {
        setState(() {
          _nCurrentValue = val;
        });
    },
    hapticFeedbackType: HapticFeedbackType.heavyImpact,
),

To use Number Slider with displaying double value:

WheelSlider.number(
    interval: 0.5, // this field is used to show decimal/double values
    perspective: 0.01,
    totalCount: _nTotalCount,
    initValue: _nInitValue,
    unSelectedNumberStyle: const TextStyle(
        fontSize: 12.0,
        color: Colors.black54,
    ),
    currentIndex: _nCurrentValue,
    onValueChanged: (val) {
        setState(() {
          _nCurrentValue = val;
        });
    },
    hapticFeedbackType: HapticFeedbackType.heavyImpact,
),

To use Custom Widget Slider:

WheelSlider.customWidget(
    totalCount: 12,
    initValue: 5,
    isInfinite: false,
    scrollPhysics: const BouncingScrollPhysics(),
    children: List.generate(12, (index) => const Center(
        child: FlutterLogo(
            size: 100,
        ),
    )),
    onValueChanged: (val) {
        setState(() {
          _cCurrentValue = val;
        });
    },
    hapticFeedbackType: HapticFeedbackType.vibrate,
    showPointer: false,
    itemSize: 80,
),
🛠️ Properties
  • controller - A FixedExtentScrollController that allows you to manage and control the scroll position of the slider.
  • interval - To display decimal values. By default it is set to 1, when changed totalCount also to be updated accordingly.
  • currentIndex - Gets the current value as you scroll the Number Slider.
  • perspective - Change the way you want the slider to look from a flat to a wheel like shape and the value must be <= 0.01.
  • squeeze - Adjust the spacing between each item in the slider.
  • isVibrate - To turn on/off vibration while scrolling.
  • hapticFeedbackType - Allows you to change the vibration type.
  • itemSize - Size of each item in the slider.
  • background - Use any widget to add as a background to the slider.
  • allowPointerTappable:
    • When this is set to false scroll functionality won't work for the occupied region.
    • When using customPointer with GestureDetector/InkWell, set it to false to enable gestures.
    • When using default pointer set it to default state i.e true.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。