showBigFlightDatePicker method

void showBigFlightDatePicker(
  1. dynamic positionKey,
  2. dynamic context
)

Implementation

void showBigFlightDatePicker(positionKey, context) {
  final RenderBox renderBox =
  positionKey.currentContext!.findRenderObject() as RenderBox;
  final position = renderBox.localToGlobal(Offset.zero);
  final size = renderBox.size;
  showMenu(
    context: context,
    elevation: 8,
    surfaceTintColor: Colors.transparent,
    shadowColor: ColorHelper.shadowLight,
    shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
    color: Colors.white,
    constraints: BoxConstraints(maxWidth: 420.dp),
    position: RelativeRect.fromLTRB(
      position.dx,
      position.dy + size.height, // Position below the widget
      position.dx + size.width,
      position.dy + size.height * 2,
    ),
    items: [
      PopupMenuItem(
        enabled: false,
        child: SizedBox(
          width: 500,
          height: 250,
          child: SfDateRangePicker(
            view: DateRangePickerView.month,
            enableMultiView: true,
            selectionMode: isTempRoundTrip ? DateRangePickerSelectionMode.range : DateRangePickerSelectionMode.single,
            showActionButtons: false,
            showNavigationArrow: true,
            backgroundColor: Colors.white,
            headerStyle: const DateRangePickerHeaderStyle(
              backgroundColor: ColorHelper.white,
              textAlign: TextAlign.center,
            ),
            todayHighlightColor: Colors.transparent,
            selectionColor: ColorHelper.primaryColor1,
            startRangeSelectionColor: ColorHelper.primaryColor1,
            endRangeSelectionColor: ColorHelper.primaryColor1,
            rangeSelectionColor: ColorHelper.primaryColor1.withOpacity(0.12),
            minDate: DateTime.now(),
            onSelectionChanged: (args) {
              if (!isTempRoundTrip) {
                String formattedDate = DateFormat('EEE, dd/MM/yy')
                    .format(args.value as DateTime);
                searchDepartureDate.value = formattedDate;
                closeDialog();
              } else {
                final range = args.value as PickerDateRange;
                String formattedDate1 = DateFormat('EEE, dd/MM/yy')
                    .format(range.startDate ?? DateTime(1990));
                searchDepartureDate.value = formattedDate1;
                searchReturnDate.value = '';
                if (range.endDate != null) {
                  String formattedDate2 = DateFormat('EEE, dd/MM/yy')
                      .format(range.endDate ?? DateTime(1990));
                  searchReturnDate.value = formattedDate2;
                  closeDialog();
                }
              }
            },
          ),
        ),
      ),
    ],
  );
}