Is it possible have a YEAR-MONTH picker with only the month and the year with the current showDatePicker without using third-party PLUGINS!!
Note: As a result the day selection layout should not be visible.
DatePicker is a material widget in a flutter that lets the user select a date. Since there is no widget available for creating a date picker we will use showDatePicker() function. It will display a Material Design date picker in a dialog by calling flutter's inbuilt function.
Use flutter_datetime_picker with custom model which disables the last column
class CustomMonthPicker extends DatePickerModel {
CustomMonthPicker({DateTime currentTime, DateTime minTime, DateTime maxTime,
LocaleType locale}) : super(locale: locale, minTime: minTime, maxTime:
maxTime, currentTime: currentTime);
@override
List<int> layoutProportions() {
return [1, 1, 0];
}
}
and show the picker with custom model
DatePicker.showPicker(context,
...
pickerModel: CustomMonthPicker(
minTime: DateTime(2020, 1, 1),
maxTime: DateTime.now(),
currentTime: DateTime.now()
)
...
)
The stock pickers do not allow to have month and year only.
You could use the month_picker_dialog package available in the pub page by Dimitri Krivoj.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With