搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。