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

month_year_picker 封面
套件詳情v0.5.0+1

month_year_picker

受 Flutter 日期選擇器設計啟發的月份年份選擇器。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
23
喜歡數
92
Pub 分數
160

安裝套件

flutter pub add month_year_picker

套件介紹

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

一個 Flutter 套件,提供了一個月與年選擇器元件,靈感來自 Flutter 原生日期選擇器設計。它讓使用者能在乾淨直覺的介面中選擇特定的月份與年份,非常適合需要日期輸入但不需精確到日的表單。此選擇器完全可自訂,並支援所有主要平台,包含 Android、iOS、Web、macOS、Windows 與 Linux。建構時考量了 Flutter 的 Material 與 Cupertino 主題,確保跨裝置的 UI 一致性。

適用情境

  • 選擇出生月份和年份
  • 按月和年過濾資料
  • 設定紀念日日期
  • 設定訂閱開始日期
  • 進入畢業年份

主要特色

  • Material 與 Cupertino 主題支援
  • 跨平台相容性
  • 可自訂外觀
  • 簡單的 API 結合
  • 流暢的動畫
  • 無對外部庫的依賴

適合對象

  • 需要選擇月份/年份的表單輸入
  • 基於日曆的應用程式
  • 使用者檔案設定流程
  • 數據過濾介面
  • 具有日期相關功能的移動和網頁應用

使用建議

  • 不包含日期選擇
  • 僅限月份和年份
  • 需要手動處理日期格式化
  • 不適用於精確的日期範圍
  • 可能需要額外的業務邏輯驗證

原始 README

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

Material Month/Year Picker

Pub GitHub Workflow Status

The month year picker inspired by the Flutter's date picker design.

Quick Start

  1. Open your pubspec.yaml file and add this entry:

    month_year_picker: ^0.5.0+1
    

    OR just run flutter pub add month_year_picker using your preferred terminal app.

  2. Then run flutter pub get.

  3. Import this library into your code:

    import 'package:month_year_picker/month_year_picker.dart';
    

    Additionally, ensure your MaterialApp refers to the following localizationsDelegates:

        GlobalMaterialLocalizations.delegate,
        MonthYearPickerLocalizations.delegate,
    
  4. Usage in code:

    final selected = await showMonthYearPicker(
      context: context,
      initialDate: DateTime.now(),
      firstDate: DateTime(2019),
      lastDate: DateTime(2023),
    );
    

Parameters

Parameter Description
context Must not be null. Will be passed to the internal showDialog function call.
initialDate Must not be null and must fall between the firstDate and lastDate. The initialDate will be truncated to its year and month components. When the month/year picker is first displayed, it will show the month/year of the initialDate, with initialDate selected.
firstDate Must not be null. The firstDate will be truncated to its year and month components. This is the earliest allowable month/year.
lastDate Must not be null. The lastDate will be truncated to its year and month components. This is the latest allowable month/year.
selectableMonthYearPredicate Can be null. The function to provide full control over which month/year can be selected. If provided, only the month/year that the selectableMonthYearPredicate returns true for will be selectable.
locale Can be null. If provided, will be used to set the locale for the month/year picker. Otherwise, it defaults to the ambient locale provided by Localizations.
useRootNavigator Can be null. Will be passed to the internal showDialog function call.
routeSettings Can be null. Will be passed to the internal showDialog function call.
textDirection Can be null. If provided, will be used to set the text direction for the month/year picker. Otherwise, it defaults to the ambient locale provided by Directionality.
builder Can be null. This parameter can be used to wrap the dialog widget with a parent widget.
initialMonthYearPickerMode Must not be null. Can be used to have the year picker initially appear in the MonthYearPickerMode.year mode. It defaults to the MonthYearPickerMode.month mode.

Screenshots

Mode Screenshot
Month picker in portrait mode with default locale.
Year picker in portrait mode with default locale.
Month picker in portrait mode with Malay locale.
Year picker in portrait mode with Malay locale.
Month picker in portrait mode with Arabic locale.
Year picker in portrait mode with Arabic locale.
Month picker in landscape mode with default locale.
Year picker in landscape mode with default locale.
Month picker in landscape mode with Malay locale.
Year picker in landscape mode with Malay locale.
Month picker in landscape mode with Arabic locale.
Year picker in landscape mode with Arabic locale.

Building From Source

Dependencies
  1. Dart SDK version 3.8.0 or newer.
  2. Flutter SDK version 3.32 or newer.
Steps
  1. Clone this git repo into your machine.
  2. Run .\gen-l10n.ps1 to re-generate the localised strings.

Features and Bugs

Please file feature requests and bugs at the issue tracker.

License

This project is licensed under the MIT License - see the LICENSE file for details.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。