showDatePicker static method

dynamic showDatePicker({
  1. dynamic onConfirm(
    1. DateTime date
    )?,
  2. String? cancelText,
  3. String? confirmText,
  4. bool useSafeArea = false,
})

Implementation

static showDatePicker(
    {Function(DateTime date)? onConfirm,
    String? cancelText,
    String? confirmText,
    bool useSafeArea = false}) {
  DateTime date = DateTime.now();
  showModalBottomSheet(
    context: Get.context!,
    useSafeArea: useSafeArea,
    builder: (BuildContext context) => SizedBox(
      height: 300.h,
      child: Column(
        children: [
          Padding(
            padding: EdgeInsets.only(
                top: CommonStyle.spaceMd,
                left: CommonStyle.spaceLg,
                right: CommonStyle.spaceLg),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                GestureDetector(
                  onTap: () => Get.back(),
                  child: Text(
                    cancelText ?? "Cancel",
                    style: CommonStyle.titleStyle,
                  ),
                ),
                GestureDetector(
                  onTap: () {
                    onConfirm?.call(date);
                    Get.back();
                  },
                  child: Text(
                    confirmText ?? "Confirm",
                    style: CommonStyle.titleStyle
                        .copyWith(color: CommonColors.theme),
                  ),
                ),
              ],
            ),
          ),
          SizedBox(
            height: 250.h,
            child: CupertinoDatePicker(
                mode: CupertinoDatePickerMode.date,
                onDateTimeChanged: (DateTime newDate) {
                  date = newDate;
                }),
          )
        ],
      ),
    ),
  );
}