搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目