onTapDob method

Future<void> onTapDob(
  1. GlobalKey<State<StatefulWidget>> dobKey,
  2. BuildContext context
)

Implementation

Future<void> onTapDob(GlobalKey dobKey, BuildContext context) async {
  final RenderBox renderBox = dobKey.currentContext!.findRenderObject() as RenderBox;
  final position = renderBox.localToGlobal(Offset.zero);
  final size = renderBox.size;
  showMenu(
    context: context,
    elevation: 8,
    surfaceTintColor: Colors.transparent,
    shadowColor: ColorHelper.black,
    shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
    color: Colors.white,
    constraints: BoxConstraints(maxWidth: 420.dp),
    position: RelativeRect.fromLTRB(
      position.dx,
      position.dy + size.height,
      position.dx + size.width,
      position.dy + size.height * 2,
    ),
    items: [
      PopupMenuItem(
        enabled: false,
        child: Container(
          width: 500.dp,
          alignment: Alignment.center,
          child: CalendarDatePicker2(
            onValueChanged: (value) {
              String formattedDate = DateFormat('yyyy-MM-dd').format(value.firstOrNull ?? DateTime(1990));
              dobController.text = formattedDate;
              selectedNationality.refresh();
              specificPassenger.refresh();
              closeDialog();
            },
            displayedMonthDate: DateTime(1990),
            value: const [],
            config: CalendarDatePicker2Config(
              weekdayLabels: ['SUN','MON', 'TUE', 'WED', 'THU', 'FRI','SAT'],
              weekdayLabelTextStyle: const TextStyle(
                  fontWeight: FontWeight.w600,
                  color: ColorHelper.neutralLightText
              ),
              disabledDayTextStyle: const TextStyle(
                  fontWeight: FontWeight.w400,
                  color: ColorHelper.neutralLight1
              ),
              dayTextStyle: const TextStyle(
                  fontWeight: FontWeight.w400,
                  color: ColorHelper.neutralDark
              ),
              todayTextStyle:  const TextStyle(
                  fontWeight: FontWeight.w500,
                  color: ColorHelper.primaryColor1
              ),
              daySplashColor: ColorHelper.primaryColor1,
              selectedDayHighlightColor: ColorHelper.primaryColor1,
              selectedRangeHighlightColor: ColorHelper.primaryColor1,
              firstDate: DateTime(1930),
              lastDate: DateTime.now(),
              calendarType: CalendarDatePicker2Type.single,
            ),
          ),
        ),
      ),
    ],
  );
}