How to disable edit button/input mode in showDatePicker flutter

Viewed 5673

I'm using showDatePicker function to pick a date from the dialog Calendar. It shows an edit icon at the top right (see img 1) to change to input mode where the user can enter the date as a text (see img 2)

How to block/disable the edit button/input mode from showing at the top right? I want to remove this icon, because I dont want to use it.

Help me thanks

img 1 img 1

img 2 img 2

5 Answers

Use initialEntryMode

final DateTime? picked = await showDatePicker(
      context: context,
      initialDatePickerMode: DatePickerMode.day,
      initialDate: DateTime.now(),
      firstDate: DateTime(2015),
      lastDate: DateTime(2101),
      initialEntryMode: DatePickerEntryMode.calendarOnly, // <- this
    );

For disabling the Edit icon, all you have to set:

initialEntryMode: DatePickerEntryMode.calendarOnly,

There is no option to disable that feature. it is the newest feature in flutter 1.17 on datePicker.

You can set initialEntryMode to DatePickerEntryMode.calendar or DatePickerEntryMode.input but cannot disable it. For example:

var picked = await showDatePicker(
  initialEntryMode: DatePickerEntryMode.input,
  context: context,
  ...
)

Flutter team have fixed the problem with input format. Thanks for help

Related