10.7 C
New York
Wednesday, November 27, 2024

ios – DatePicker not engaged on flutter internet solely on sure telephones


I’ve a join kind which incorporates customers to pick out their date of beginning. Apparently the whole lot works nicely on desktop internet nonetheless iphone customers who’re beneath than 18.1.1 can open the datepicker however cant choose a date. At first I believed it was a datepicker problem for iphone customers so i take advantage of one other datepicker that was engaged on a previous venture. However then, apparently the datepicker problem additionally occurs to be affecting on sure android telephones similar to Samsung Galaxy S23 Extremely and Samsung Z Flip 3.Beneath is my code.

TextFormField(
                        controller: controller.dateController,
                        validator: (worth) {
                          if (worth!.isEmpty) {
                            return 'Please choose your Date of Start';
                          }
                          return null;
                        },
                        readOnly: true,
                        ornament: InputDecoration(
                          contentPadding: EdgeInsets.solely(high:5),
                          labelText: 'Date of Start',
                          labelStyle: ISCustomTextStyles.titleMediumOnPrimary
                              .copyWith(fontSize: getFontSize(18)),
                          enabledBorder: UnderlineInputBorder(
                            borderSide:
                            BorderSide(shade: ISAppTheme.lime800),
                          ),
                          focusedBorder: UnderlineInputBorder(
                            borderSide:
                            BorderSide(shade: ISAppTheme.lime800),
                          ),
                          suffixIcon: Rework.scale(
                            scale: 0.6, // Shrink the icon measurement
                            youngster: ImageIcon(
                              AssetImage(ImageConstant.calendarIcon),
                              shade: ISAppTheme.gray300, // Icon shade
                            ),
                          ),

                        ),
                        onTap: () => controller.selectDate(),

The beneath code known as in one other file which is the controller

Future selectDate() async {
if(defaultTargetPlatform != TargetPlatform.iOS){
  DateTime? pickedDate = await showDatePicker(
    context: Get.context!,
    initialDate: DateTime.now(),
    firstDate: DateTime(1900),
    locale: Locale("en"),
    lastDate: DateTime(DateTime.now().yr, 12, 31),
    initialEntryMode: DatePickerEntryMode.calendarOnly,
  );
  if (pickedDate != null) {
    String formattedDate = DateFormat('dd-MM-yyyy').format(pickedDate);
    dateController.textual content = formattedDate;
    dateOfBirth.worth = pickedDate;
  }
}


else {
      DateTime? pickedDate = await DatePicker.showSimpleDatePicker(
        Get.context!,
        initialDate: DateTime.now(),
        firstDate: DateTime(1900),
        lastDate: DateTime(DateTime.now().yr, 12, 31),
        dateFormat: "dd-MMMM-yyyy",
        locale: DateTimePickerLocale.en_us,
        looping: true,
      );
      if (pickedDate != null) {
        String formattedDate = DateFormat('dd-MM-yyyy').format(pickedDate);
        dateController.textual content = formattedDate;
        dateOfBirth.worth = pickedDate;
      }
    }

  }

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles