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

套件詳情v1.6.0

flutter_picker_plus

透過 NumberPicker、DateTimePicker、ArrayPicker 和預設連結 Picker 提供靈活的參數以滿足各種需求。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1.2萬
喜歡數
63
Pub 分數
160

安裝套件

flutter pub add flutter_picker_plus

套件介紹

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

Flutter Picker Plus 是一個多功能選擇器庫,提供可自定義的 NumberPicker、DateTimePicker、ArrayPicker 與連結選擇器功能。設計上具備高度彈性,支援多種設定,以符合跨平台的各種介面需求。可在 Android、iOS、Web、macOS、Windows 及 Linux 上順暢整合,讓開發者能輕鬆建立動態且互動式的選取介面。此套件透過提供針對不同資料類型與使用情境優化的流暢、即時反應的選擇器,大幅提升使用者體驗。

適用情境

  • 帶有數值輸入的表單欄位
  • 應用中的日期和時間選擇
  • 帶有陣列選項的自訂下拉選單
  • 多層連結選擇
  • 動態表單建構器
  • 使用者偏好設定

主要特色

  • 支援多種選擇器類型
  • 可設定的巢狀選擇連結
  • 跨平台相容性
  • 可擴展的自訂選項
  • 流暢的動畫
  • 響應式設計

適合對象

  • 開發需要複雜輸入的表單的開發者
  • 需要日期/時間選擇器的應用程式
  • 具有自定義選擇組件的UI密集型應用
  • 跨平台 Flutter 項目
  • 尋求可重複使用選擇器解決方案的團隊

使用建議

  • 需要了解 Flutter 狀態管理
  • 可能需要額外的樣式以保持外觀一致
  • 除了基本範例之外,文件內容有限
  • 大資料集可能帶來的效能影響
  • 不適合簡單的單值選擇

原始 README

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

flutter_picker_plus

pub package License

A powerful and customizable picker widget for Flutter applications. Continuation of the popular flutter_picker package with enhanced features and modern Flutter support.

Picker Demo

✨ Features

  • 🎯 Multiple Picker Types: Number, DateTime, Array, and custom data pickers
  • 🌐 Internationalization: Support for 20+ languages including RTL languages
  • 🎨 Highly Customizable: Flexible styling, colors, and layouts
  • 🔗 Linkage Support: Create dependent picker columns
  • 📱 Multiple Display Modes: Modal, dialog, and embedded pickers
  • 🎭 Custom Adapters: Extend functionality with your own data adapters
  • 🛡️ Null Safety: Full null safety support
  • ⚡ Performance Optimized: Handles large datasets efficiently

🚀 Installation

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_picker_plus: ^1.5.6

📋 Requirements

  • Flutter: 3.32.0 or higher
  • Dart: 3.0.0 or higher

For Flutter version history and migration guides, see the Flutter Release Notes.

🌍 Supported Languages

Arabic • Bengali • Chinese • English • French • German • Greek • Hindi • Indonesian • Italian • Japanese • Korean • Portuguese • Romanian • Russian • Spanish • Turkish • Urdu • Javanese • Vietnamese • Slovenian

Supporting 20+ languages including the most widely spoken languages worldwide.

📖 Quick Start

Basic String Picker
import 'package:flutter_picker_plus/flutter_picker_plus.dart';

void showBasicPicker(BuildContext context) {
  Picker(
    adapter: PickerDataAdapter<String>(
      pickerData: ['Option 1', 'Option 2', 'Option 3']
    ),
    title: const Text('Select an Option'),
    onConfirm: (Picker picker, List<int> value) {
      print('Selected: ${picker.getSelectedValues()}');
    },
  ).showModal(context);
}
Number Picker
void showNumberPicker(BuildContext context) {
  Picker(
    adapter: NumberPickerAdapter(data: [
      const NumberPickerColumn(begin: 0, end: 100, jump: 5),
      const NumberPickerColumn(begin: 0, end: 60),
    ]),
    delimiter: [
      PickerDelimiter(
        child: Container(
          width: 30.0,
          alignment: Alignment.center,
          child: const Text(':'),
        ),
        column: 1,
      ),
    ],
    title: const Text('Select Time'),
    onConfirm: (Picker picker, List<int> value) {
      print('Selected: ${picker.getSelectedValues()}');
    },
  ).showModal(context);
}
Date Time Picker
void showDateTimePicker(BuildContext context) {
  Picker(
    adapter: DateTimePickerAdapter(
      type: PickerDateTimeType.kYMDHM,
      value: DateTime.now(),
      minValue: DateTime(1950),
      maxValue: DateTime(2050),
    ),
    title: const Text('Select Date & Time'),
    onConfirm: (Picker picker, List<int> value) {
      final dateTime = (picker.adapter as DateTimePickerAdapter).value;
      print('Selected: $dateTime');
    },
  ).showModal(context);
}

🎛️ Advanced Usage

Multi-Column Array Picker
void showArrayPicker(BuildContext context) {
  Picker(
    adapter: PickerDataAdapter<String>(
      pickerData: [
        ['Morning', 'Afternoon', 'Evening'],
        ['Coffee', 'Tea', 'Juice'],
        ['Small', 'Medium', 'Large'],
      ],
      isArray: true,
    ),
    title: const Text('Customize Your Order'),
    onConfirm: (Picker picker, List<int> value) {
      print('Selected: ${picker.getSelectedValues()}');
    },
  ).showModal(context);
}
Hierarchical (Linkage) Picker
void showLinkagePicker(BuildContext context) {
  final data = {
    'Fruits': {
      'Citrus': ['Orange', 'Lemon', 'Lime'],
      'Berries': ['Strawberry', 'Blueberry', 'Raspberry'],
    },
    'Vegetables': {
      'Root': ['Carrot', 'Potato', 'Onion'],
      'Leafy': ['Lettuce', 'Spinach', 'Kale'],
    },
  };

  Picker(
    adapter: PickerDataAdapter<String>(pickerData: [data]),
    title: const Text('Select Food Category'),
    onConfirm: (Picker picker, List<int> value) {
      print('Selected: ${picker.getSelectedValues()}');
    },
  ).showModal(context);
}
Custom Styling
void showStyledPicker(BuildContext context) {
  Picker(
    adapter: PickerDataAdapter<String>(
      pickerData: ['Red', 'Green', 'Blue', 'Yellow'],
    ),
    backgroundColor: Colors.grey.shade100,
    headerColor: Colors.blue,
    containerColor: Colors.white,
    textStyle: const TextStyle(color: Colors.black87, fontSize: 18),
    cancelTextStyle: const TextStyle(color: Colors.red),
    confirmTextStyle: const TextStyle(color: Colors.blue),
    itemExtent: 50.0,
    diameterRatio: 2.0,
    title: const Text('Pick a Color'),
    onConfirm: (Picker picker, List<int> value) {
      print('Selected: ${picker.getSelectedValues()}');
    },
  ).showModal(context);
}

🔧 API Reference

Picker Class
Property Type Description
adapter PickerAdapter Data adapter for the picker
title Widget? Title widget displayed at the top
cancelText String? Cancel button text (default: localized)
confirmText String? Confirm button text (default: localized)
backgroundColor Color? Background color of the picker
headerColor Color? Header background color
textStyle TextStyle? Style for picker items
hideHeader bool Hide the header buttons (default: false)
delimiter List<PickerDelimiter>? Delimiters between columns
Available Adapters
  • PickerDataAdapter: For string/custom data
  • NumberPickerAdapter: For numeric ranges
  • DateTimePickerAdapter: For date and time selection
Display Methods
  • showModal(context): Show as modal bottom sheet
  • showDialog(context): Show as dialog
  • show(state): Show with custom state (deprecated)
  • makePicker(): Return picker widget for embedding

🎨 Customization Options

Localization

The picker automatically adapts to your app's locale. You can also register custom languages:

PickerLocalizations.registerCustomLanguage(
  'custom',
  cancelText: 'Cancel',
  confirmText: 'OK',
  ampm: ['AM', 'PM'],
  months: ['Jan', 'Feb', 'Mar', /* ... */],
);
Custom Item Builder
Picker(
  adapter: adapter,
  itemBuilder: (context, text, child, selected, column, index) {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 16.0),
      decoration: BoxDecoration(
        color: selected ? Colors.blue.shade100 : null,
        borderRadius: BorderRadius.circular(8.0),
      ),
      child: child,
    );
  },
  // ... other properties
)

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

📄 License

This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.

🙏 Acknowledgments

This package is a continuation of the original flutter_picker package with additional features and improvements.


For more examples and detailed documentation, check out the example app.

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案