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

month_picker_dialog 封面
套件詳情v6.7.3

month_picker_dialog

從無限年份列表中選擇單個月份的國際化對話框。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
4.4萬
喜歡數
162
Pub 分數
160

安裝套件

flutter pub add month_picker_dialog

套件介紹

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

一個 Flutter 套件,提供國際化對話方塊,可從無限年份列表中選擇單一月份。專為跨平台無縫整合而設計,支援本地化,並提供乾淨直覺的日期選擇介面。該對話方塊動態處理年份導航,並確保在 Android、iOS、Web、macOS、Windows 及 Linux 上的可存取性與響應性。非常適合需要按月級別輸入日期並具備全球語言支援的應用程式。

適用情境

  • 在表單中選擇月份
  • 按月份篩選資料
  • 設定每月偏好
  • 基於日期的報告
  • 使用者資料設定
  • 日曆相關功能

主要特色

  • 國際化支援
  • 無限年份滾動
  • 跨平台相容性
  • 本地化文字與格式化
  • 簡單的 API 結合
  • 響應式設計

適合對象

  • 需要月份選擇的應用
  • 面向多語言用戶的全球應用
  • 需要日期的表單輸入
  • 按月資料過濾
  • 開發者尋找輕量級日期選擇器

使用建議

  • 不支援單獨選擇年份
  • 僅限單月選擇
  • 無內建驗證
  • 需要手動處理選定的日期
  • 未針對超過月視圖的大資料集進行優化

原始 README

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

month_picker_dialog

Build Status pub package

Internationalized material style dialog for picking a single month from an infinite list of years. This package makes use of the intl package and flutter's i18n abilities to provide labels in all languages known to flutter.

Buy Me A Coffee

Setting up an internationalized app: the flutter localization package

LTR portrait

How to use it:

Just add:

showMonthPicker() to select a single month;

showMonthRangePicker() to select a range of months;

showYearPicker() to select only a year;

...inside your button function like a normal date picker dialog (context parameter is required):

Example:
FloatingActionButton(
    onPressed: () {
        showMonthPicker(
        context: context,
        initialDate: DateTime.now(),
        ).then((date) {
        if (date != null) {
            setState(() {
            selectedDate = date;
            });
        }
        });
    },
    child: Icon(Icons.calendar_today),
),

FloatingActionButton(
    onPressed: () {
        showMonthRangePicker(
        context: context,
        initialDate: DateTime.now(),
        rangeList: true,
        ).then((List<DateTime>? dates) {
        if (dates != null) {
            print(dates);
            print(dates.last.lastDayOfMonth());
        }
        });
    },
    child: Icon(Icons.calendar_today),
),

FloatingActionButton(
    onPressed: () {
        showYearPicker(
        context: context,
        initialDate: DateTime.now(),
        ).then((year) {
        if (year != null) {
            setState(() {
            selectedYear = year;
            });
        }
        });
    },
    child: Icon(Icons.calendar_today),
),

Migrating to 5.0:

Starting with version 5.0.0 of the package, everything related to the behavior/style of it that isn't a function, date parameter or custom widget is now under the new MonthPickerDialogSettings class.

It contains three subclasses:

PickerDialogSettings to customize the dialog part of the package;

PickerHeaderSettings to customize the header part of the package;

PickerButtonsSettings to customize the buttons part of the package;

And will be used like this:

FloatingActionButton(
    onPressed: () {
        showMonthPicker(
        context: context,
        initialDate: DateTime.now(),
        monthPickerDialogSettings: const MonthPickerDialogSettings(
            headerSettings: PickerHeaderSettings(
                headerCurrentPageTextStyle: TextStyle(fontSize: 14),
                headerSelectedIntervalTextStyle: TextStyle(fontSize: 16),
            ),
            dialogSettings: PickerDialogSettings(
                locale: const Locale('en'),
                dialogRoundedCornersRadius: 20,
                dialogBackgroundColor: Colors.blueGrey[50],
            ),
            buttonsSettings: PickerButtonsSettings(
                buttonBorder: const RoundedRectangleBorder(),
                selectedMonthBackgroundColor: Colors.amber[900],
                selectedMonthTextColor: Colors.white,
                unselectedMonthsTextColor: Colors.black,
                currentMonthTextColor: Colors.green,
                yearTextStyle: const TextStyle(
                    fontSize: 10,
                ),
                monthTextStyle: const TextStyle(
                    fontWeight: FontWeight.bold,
                    fontSize: 18,
                ),
            ),
        ),
        ).then((date) {
        if (date != null) {
            setState(() {
            selectedDate = date;
            });
        }
        });
    },
    child: Icon(Icons.calendar_today),
),

If you have any doubts on how to use this new settings class (that the sample app can't solve), please feel free to open an issue on the github project.

Contributors:

Gian Bettega

Dimitri Krivoj (the original creator of the package)

Fabio Henrique

Leon Colt

Wesley Gonzaga

Efrain Bastidas

Volodymyr Hyrka

Bern

just1982

Sagar Zala

Pong Loong Yeat

Masayuki Ono

Alecsplus

Lautaro Zanuttini

sinelser

sheldontuitt

nomoruyi

gabrielezereik

roth-arasys

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案