I am trying to pick a date only. I used
Expected output will be -
current_date: 2022-1-1
CodePudding user response:
Create showDatePicker
function for that. Below link will helpful to you.
https://medium.com/flutter-community/a-deep-dive-into-datepicker-in-flutter-37e84f7d8d6c
https://codesinsider.com/flutter-datepicker-widget-example-tutorial/
CodePudding user response:
DatePickerWidget
's onChange
method provide DateTime
.
You can format this date with DateFormat
from intl package.
final DateFormat formatter = DateFormat('yyyy-MM-dd');
final String output = formatter.format(_selectedDate);
I will encourage you to check this answer.