showCupertinoDatePicker function

void showCupertinoDatePicker({
  1. required BuildContext context,
  2. required NepaliDateTime initialDate,
  3. required NepaliDateTime firstDate,
  4. required NepaliDateTime lastDate,
  5. required ValueChanged<NepaliDateTime> onDateChanged,
  6. Language language = Language.english,
  7. DateOrder dateOrder = DateOrder.mdy,
})

Shows Cupertino-styled nepali date picker.

Implementation

void showCupertinoDatePicker({
  required BuildContext context,
  required NepaliDateTime initialDate,
  required NepaliDateTime firstDate,
  required NepaliDateTime lastDate,
  required ValueChanged<NepaliDateTime> onDateChanged,
  Language language = Language.english,
  DateOrder dateOrder = DateOrder.mdy,
}) {
  assert(firstDate.year >= 1970 && lastDate.year <= 2100,
      'Invalid Date Range. Valid Range = [1970, 2100]');
  assert(!initialDate.isBefore(firstDate),
      'initialDate must be on or after firstDate');
  assert(!initialDate.isAfter(lastDate),
      'initialDate must be on or before lastDate');
  assert(
      !firstDate.isAfter(lastDate), 'lastDate must be on or after firstDate');

  showCupertinoModalPopup<void>(
    context: context,
    builder: (BuildContext context) {
      return Container(
        height: _kPickerSheetHeight,
        padding: const EdgeInsets.only(top: 6.0),
        color: CupertinoColors.white,
        child: DefaultTextStyle(
          style: const TextStyle(
            color: CupertinoColors.black,
            fontSize: 22.0,
          ),
          child: GestureDetector(
            onTap: () {},
            child: SafeArea(
              top: false,
              child: _CupertinoDatePicker(
                initialDate: initialDate,
                minimumYear: firstDate.year,
                maximumYear: lastDate.year,
                onDateChanged: onDateChanged,
                language: language,
                dateOrder: dateOrder,
              ),
            ),
          ),
        ),
      );
    },
  );
}