dateScrollPicker method

Widget dateScrollPicker(
  1. BuildContext context,
  2. List<DateTime> dates, {
  3. required dynamic onDateSelected(
    1. DateTime dateSelected
    ),
  4. String todayString = 'Avui',
  5. String tomorrowString = 'Demà',
  6. double pickerHeight = 180,
})

Implementation

Widget dateScrollPicker(BuildContext context, List<DateTime> dates,
    {required Function(DateTime dateSelected) onDateSelected,
    String todayString = 'Avui',
    String tomorrowString = 'Demà',
    double pickerHeight = 180}) {
  return SizedBox(
      height: pickerHeight,
      child: Row(children: [
        Expanded(
            child: CupertinoPicker(
          onSelectedItemChanged: (int value) {
            onDateSelected(dates[value]);
          },
          itemExtent: 48,
          children: List.generate(dates.length, (index) {
            return SizedBox(
              height: 48,
              child: Center(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Utils.isToday(dates[index])
                        ? DUI.text.xs(context, todayString,
                            color: Theme.of(context)
                                .textTheme
                                .bodyMedium!
                                .color!
                                .withOpacity(0.7))
                        : Utils.isTomorrow(dates[index])
                            ? DUI.text.xs(context, tomorrowString,
                                color: Theme.of(context)
                                    .textTheme
                                    .bodyMedium!
                                    .color!
                                    .withOpacity(0.7))
                            : SizedBox.shrink(),
                    DUI.text.title3(context, Utils.formatDate(dates[index]))
                  ],
                ),
              ),
            );
          }),
        )),
      ]));
}