timeScrollPicker method

Widget timeScrollPicker(
  1. BuildContext context,
  2. List<TimeOfDay> times, {
  3. required dynamic onTimeSelected(
    1. TimeOfDay timeSelected
    ),
  4. double pickerHeight = 180,
})

Implementation

Widget timeScrollPicker(BuildContext context, List<TimeOfDay> times,
    {required Function(TimeOfDay timeSelected) onTimeSelected,
    double pickerHeight = 180}) {
  return SizedBox(
      height: pickerHeight,
      child: Row(children: [
        Expanded(
            child: CupertinoPicker(
          onSelectedItemChanged: (int value) {
            onTimeSelected(times[value]);
          },
          itemExtent: 48,
          children: List.generate(times.length, (index) {
            return SizedBox(
              height: 48,
              child: Center(
                child: DUI.text
                    .title3(context, '${times[index].format(context)} h'),
              ),
            );
          }),
        ))
      ]));
}