How we can use time and date picker together in flutter?

Issue

I want to show date and time picker together but I think no any widget or lib provides this feature in flutter.
Any suggestion or solution ?

Solution

Try flutter_datetime_picker here hope its help to you.

In this package you want to pick date and time both.

Try date_time_picker package also

Updated Answer:

You used flutter_cupertino_datetime_picker and set the date format on your need

    ElevatedButton(
          onPressed: () {
            dateTimePickerWidget(context);
          },
          child: Text('Pick Date-Time'),
        ),

method for dateTimePicker:

  dateTimePickerWidget(BuildContext context) {
    return DatePicker.showDatePicker(
      context,
      dateFormat: 'dd MMMM yyyy HH:mm',
      initialDateTime: DateTime.now(),
      minDateTime: DateTime(2000),
      maxDateTime: DateTime(3000),
      onMonthChangeStartWithFirstDate: true,
      onConfirm: (dateTime, List<int> index) {
        DateTime selectdate = dateTime;
        final selIOS = DateFormat('dd-MMM-yyyy - HH:mm').format(selectdate);
        print(selIOS);
      },
    );
  }

Your Output:

16-Mar-2022 - 12:28

Result Screen for Widget -> image1

Result Screen for DateTimePicker -> enter image description here

Answered By – Ravindra S. Patil

Answer Checked By – Clifford M. (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.