Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable edit button/input mode in showDatePicker flutter

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

like image 737
mike Avatar asked Jun 08 '20 21:06

mike


3 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
    );
like image 155
Anoop Thiruonam Avatar answered Nov 04 '22 08:11

Anoop Thiruonam


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

initialEntryMode: DatePickerEntryMode.calendarOnly,
like image 45
Javier Hinmel Avatar answered Nov 04 '22 08:11

Javier Hinmel


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,
  ...
)
like image 27
Miko Avatar answered Nov 04 '22 08:11

Miko