2

I am using CupertinoDatePicker to allow user to select specific time in the current day, but i want to show text beside the selected hour and selected minute, is there any way to do this ?

This is what i am expecting

enter image description here

This is what i got

enter image description here

CupertinoDatePicker(
    mode: CupertinoDatePickerMode.time,
    use24hFormat: true,
    onDateTimeChanged: (value){
      setState(() {
        print(value);
      });
    },
)
naser
  • 33
  • 4

2 Answers2

0

You are looking for the CupertinoTimerPicker widget.

It comes up with the default labels.

example:

12 hours 12 minute

Code for the same:

          CupertinoTimerPicker(
            onTimerDurationChanged: (value) {
              setState(() {
                print(value);
              });
            },
            mode: CupertinoTimerPickerMode.hm,
            backgroundColor: Colors.red,
            initialTimerDuration: Duration(hours: 12, minutes: 12),
          ),

But, If you need the custom label as in h, m, and s in your case, you've to make a custom Cupertino time picker using existing code (from Flutter SDK).

ibhavikmakwana
  • 8,948
  • 4
  • 20
  • 39
0

You can use CupertinoTimerPicker.

Referance: CupertinoTimerPicker

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 13 '23 at 13:36