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.
This package is a fork of the original month_picker_dialog from https://github.com/hmkrivoj/month_picker_dialog with some updates and fixes.
Setting up an internationalized app: the flutter localization package
Just add showMonthPicker() inside your button function like a normal date picker dialog (context and initialDate parameters are required):
FloatingActionButton(
onPressed: () {
showMonthPicker(
context: context,
initialDate: DateTime.now(),
).then((date) {
if (date != null) {
setState(() {
selectedDate = date;
});
}
});
},
child: Icon(Icons.calendar_today),
),
There are other parameters to configure on the dialog if you want:
[initialDate] is the initially selected month.
[firstDate] is the optional lower bound for month selection.
[lastDate] is the optional upper bound for month selection.
[selectableMonthPredicate] lets you control enabled months just like the official selectableDayPredicate.
[capitalizeFirstLetter] lets you control if your months names are capitalized or not.
[headerColor] lets you control the calendar header color.
[headerTextColor] lets you control the calendar header text and arrows color.
[selectedMonthBackgroundColor] lets you control the current selected month/year background color.
[selectedMonthTextColor] lets you control the text color of the current selected month/year.
[unselectedMonthTextColor] lets you control the text color of the current unselected months/years.
[confirmText] lets you set a custom confirm text widget.
[cancelText] lets you set a custom cancel text widget.
[customHeight] lets you set a custom height for the calendar widget.
[customWidth] lets you set a custom width for the calendar widget.
[yearFirst] lets you define that the user must select first the year, then the month.
[dismissible] lets you define if the dialog will be dismissible by clicking outside it.