Search code examples
fluttertimepickershowtimepicker

Flutter showTimePicker height


I use flutter and showTimePicker. The code below works correctly on most phones. But on some phones the height is not enough.

              TimeOfDay pickedTime = await showTimePicker(
                        context: context,
                        helpText: AppLocalizations.of(context)
                            .translate('select_time'),
                        cancelText: AppLocalizations.of(context)
                            .translate('not_now'),
                        confirmText:
                            AppLocalizations.of(context).translate('done'),
                        initialTime: TimeOfDay.now().add(),
                        initialEntryMode: TimePickerEntryMode.input,
                        builder: (context, childWidget) {
                          return MediaQuery(
                              data: MediaQuery.of(context)
                                  .copyWith(alwaysUse24HourFormat: true),
                              child: childWidget);
                        });

Corrupt image as below. enter image description here


Solution

  • I solved this question below code.

    return MediaQuery(
           data: MediaQuery.of(context).copyWith(
                 alwaysUse24HourFormat: true,
                 textScaleFactor: 1),
           child: childWidget);