As you can see the dateFormat of CupertinoDatePicker
is year month day.
But I want show year and month only.
How can I do it?
Here is my code:
SizedBox(
width: 500,
height: 250,
child: CupertinoDatePicker(
mode: CupertinoDatePickerMode.date,
backgroundColor: Colors.black54,
dateOrder: DatePickerDateOrder.ymd,
onDateTimeChanged: (date) {
print(date);
},
),
),
4
Answers
Please try to use
flutter_cupertino_date_picker
andflutter_cupertino_datetime_picker
hope this is help to you.You cannot hide it directly as there is no such method for hiding it. But what you can do is go to the
'/Users/your_user_name/developer/flutter/packages/flutter/lib/src/cupertino/date_picker.dart'
and copy the complete code from that file. Now go to your project directory and create a new dart file with anyName.dart and paste the whole code there. And search for the below Text widget in the file.Here replace the
localizations.datePickerDayOfMonth(day)
with empty string ‘ ‘ like that.Then where you need to use the customed Picker call it like:
and use it
Here are some examples of formatting symbols that you can use in the dateFormat string:
(e.g. 1, 2, 3, 11, 12, etc.).
11, 12, etc.).
etc.).
Tuesday, etc.).
11, 12, etc.).
etc.).
etc.).
date formats:
copy the code from URL and save it anywhere in the lib. use code