パッケージ、リポジトリ、アプリカテゴリを検索

wheel_picker のカバー
パッケージ詳細v0.4.0

wheel_picker

入力ホイールを使用した値/時刻選択ウィジェット。カスタマイズ可能で軽量です。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1.2万
いいね数
83
Pub ポイント
160

パッケージをインストール

flutter pub add wheel_picker

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

値や時間を選択するためのホイールベースのピッカーを実装する、軽量でカスタマイズ可能なFlutterウィジェットです。ネイティブなスピンナーにインスパイアされており、プラットフォーム間で滑らかなスクロールと直感的な操作を提供します。日付、時間、または離散値を選択する必要があるフォームに最適です。パッケージは効率的かつ簡単に統合できるように設計されており、Android、iOS、Web、macOS、Windows、Linuxをサポートしています。外観や動作をカスタマイズするための明確なAPIを提供し、大きなオーバーヘッドを追加せずに済みます。

用途

  • 離散的なオプションを持つフォーム入力
  • 時間選択インターフェース
  • カスタム数値またはドロップダウンピッカー
  • 視覚フィードバック付きのデータ入力
  • マルチホイール値選択

主な機能

  • スムーズスクロールアニメーション
  • クロスプラットフォーム互換性
  • カスタマイズ可能な外観
  • 軽量なパフォーマンス
  • フォームフィールドとの簡単な統合
  • 設定可能なアイテムの間隔とサイズ

適している対象

  • フォーム中心のアプリを開発する開発者
  • ネイティブ風のピッカーが必要なUIデザイナー
  • 時間または値の選択が必要なアプリ
  • 最小バンドルサイズを最優先とするプロジェクト
  • 複数のプラットフォームをターゲットにするチーム

注意事項

  • 制限された組み込み検証
  • 自動キーボード統合なし
  • 選択イベントの手動処理が必要です
  • 非常に大きなデータセットには最適化されていない
  • ダークモード用に追加のスタイリングが必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Wheel Picker

A superset version of original ListWheelScrollView for easily creating wheel scroll input.

Flutter Pub

Left Gif Right Gif

Key Features

  • Item Selection: Retrieve the selected item index effortlessly.
  • Highlight Selection: Highlight selected items with a color shader.
  • Tap Navigation: Enable tap scrolls.
  • Horizontal Scroll Direction: Horizontal wheel scroll view.
  • Styling Flexibility: Customize wheel appearance with WheelPickerStyle.
  • Precise Control: Manage and synchronize WheelPicker widgets with a WheelPickerController.
  • Mounting Controllers: Easily integrate and shift multiple controllers.

Installing

Add it to your pubspec.yaml file:

dependencies:
  wheel_picker: ^0.3.0

Install packages from the command line:

flutter packages get

Usage

To use package, just import package import 'package:wheel_picker/wheel_picker.dart';

Example

Here's a quick example to get you started:

const daysOfWeek = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
return WheelPicker(
  itemCount: 7,
  builder: (context, index) => Text(daysOfWeek[index]),
  selectedIndexColor: Colors.orange,
  looping: false,
);
Basic (Left Gif)

For more control, you can attach a controller and adjust it to your liking:

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:wheel_picker/wheel_picker.dart';

class WheelPickerExample extends StatelessWidget {
  const WheelPickerExample({super.key});

  @override
  Widget build(BuildContext context) {
    final secondsWheel = WheelPickerController(itemCount: 10);
    const textStyle = TextStyle(fontSize: 32.0, height: 1.5);

    Timer.periodic(const Duration(seconds: 1), (_) => secondsWheel.shiftDown());

    return WheelPicker(
      builder: (context, index) => Text("$index", style: textStyle),
      controller: secondsWheel,
      selectedIndexColor: Colors.blue,
      onIndexChanged: (index, interactionType) => print("On index $index"),
      style: WheelPickerStyle(
        itemExtent: textStyle.fontSize! * textStyle.height!, // Text height
        squeeze: 1.25,
        diameterRatio: .8,
        surroundingOpacity: .25,
        magnification: 1.2,
      ),
    );
  }
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Flutter Example',
      home: Scaffold(
        body: Center(
          child: WheelPickerExample(),
        ),
      ),
    );
  }
}

void main() => runApp(const MyApp());

Note: This works for this short example but don't forget to manually dispose controllers you initialize youself.

Advanced (Right Gif)

For more advanced usage, you can also mount controllers, making them shift each other. See example.

Example: Listening for the scroll end event
const daysOfWeek = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];

return NotificationListener(
  onNotification: (notification) {
    if (notification is ScrollEndNotification) {
      print('User has ended scrolling');
    }
    return false;
  },
  child: WheelPicker(
    itemCount: 7,
    builder: (context, index) => Text(daysOfWeek[index]),
    selectedIndexColor: Colors.orange,
    looping: false,
  ),
);


Feel free to share your feedback, suggestions, or contribute to this package :handshake:.

If you like this package, consider supporting it by giving it a star on GitHub and a like on pub.dev :heart:.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。