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

selector_wheel 封面
套件詳情v1.1.2

selector_wheel

一個用於建立可自訂值選擇輪的 Flutter 套件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
174
喜歡數
30
Pub 分數
130

安裝套件

flutter pub add selector_wheel

套件介紹

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

一個 Flutter 套件,可實現可自訂的互動式數值選擇輪,用於使用者輸入。它提供了一種視覺上吸引人的方法,透過旋轉輪盤選擇數值,非常適合設定、計時器或任何需要直觀數字或分類選擇的情境。此輪盤支援平滑動畫、自訂樣式以及跨平台的響應式行為。專為尋求替代傳統文字欄位或下拉選單並提升使用者體驗的開發者設計。

適用情境

  • 帶有視覺反饋的表單輸入
  • 時間或數量選擇器
  • 遊戲化使用者介面
  • 具有可調參數的設定
  • 互動式教育工具

主要特色

  • 可自訂的輪盤外觀
  • 平滑旋轉動畫
  • 響應式觸控與拖曳支援
  • 對離散值和連續值的支援
  • 跨平台相容性

適合對象

  • 開發互動式 UI 的開發者
  • 需要直覺式值選擇的應用程式
  • 希望擁有獨特表單元素的設計師
  • 針對多個平台的專案

使用建議

  • 在低階設備上可能需要效能調校
  • 有限的內建驗證
  • 未針對非常大的值範圍進行優化
  • 需要仔細設計以確保可存取性

原始 README

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

Selector Wheel

pub package codecov

A Flutter package for creating customizable selector wheel widgets.

Table of Contents

Features

  • Customizable selector wheel widget
  • Supports variable wheel size, item width, item height, and more
  • Built with Flutter's best practices for optimal performance
  • Supports haptic feedback, fade-out effect, and more
  • Can be used with any data type

Usage example regular Usage example with bottom sheet

Getting started

Add selector_wheel to your pubspec.yaml by running the following command:

flutter pub add selector_wheel

Usage

Import the package:

import 'package:selector_wheel/selector_wheel.dart';
Basic usage

Use the SelectorWheel widget in your app:

SizedBox(
  width: 200,
  height: 200,
  child: SelectorWheel(
    childCount: 10,
    // convertIndexToValue is a function that converts the index of the
    // child to a value that is displayed on the selector wheel. In this
    // case, we are converting the index to a string. I.e we'll have
    // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 on the selector wheel.
    convertIndexToValue: (int index) {
      return SelectorWheelValue(
        label: index.toString(),
        value: index,
        index: index,
      );
    },
    onValueChanged: (SelectorWheelValue<int> value) {
      // print the value that was selected
      print(value);
    },
  ),
)
Customizing the selector wheel

Keep in mind, that the convertIndexToValue function can be used to convert the index to any value. In the example below, we are converting the index to a double value to represent quarter lbs.

SizedBox(
  width: 200,
  height: 200,
  child: SelectorWheel(
    childCount: 10,
    convertIndexToValue: (int index) {
      // This is just to illustrate, that the index can be converted
      // to any value. In this case, we are converting the index to
      // a quarter of a pound.
      final quarter = index / 4;

      return SelectorWheelValue(
        // The label is what is displayed on the selector wheel
        label: '${quarter.toString()} lb',
        value: quarter,
        index: index,
      );
    },
    onValueChanged: (SelectorWheelValue<double> value) {
      // print the value that was selected
      print(value);
    },
  ),
)

The colors of the selector wheel can be customized by overriding the ThemeData in the following way:

// Overriding the colors of the selector wheel
Theme(
  data: ThemeData(
    textTheme: Theme.of(context).textTheme.copyWith(
      titleLarge: Theme.of(context).textTheme.titleLarge?.copyWith(
        fontSize: 24.0,
        fontWeight: FontWeight.w600,
      ),
    ),
    colorScheme: Theme.of(context).colorScheme.copyWith(
      surface: Colors.black,
      onSurface: Colors.white,
      secondaryContainer: Colors.amber,
    ),
  ),
  child: SizedBox(
    width: 200,
    height: 200,
    child: SelectorWheel(
      childCount: 10,
      highlightBorderRadius: 16.0,
      highlightHeight: 40.0,
      highlightWidth: 100.0,
      convertIndexToValue: (int index) {
        return SelectorWheelValue(
          label: index.toString(),
          value: index,
          index: index,
        );
      },
      onValueChanged: (value) {
        // print the value that was selected
        print(value);
      },
    ),
  ),
)

Notice, that we're also customizing the "highlighted" item's border radius, height, and width. To see all the customizable properties, check out the SelectorWheel class.

Contributing

Contributions are welcome! If you find a bug or have a feature request, please open an issue on the GitHub repository.

License

This package is licensed under the MIT License. For more details, please refer to the LICENSE file included in the repository.

所屬分類

依賴

依賴清單 3 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。