GaspardMerten / date_field

Flutter DateField and DateFormField
Other
45 stars 32 forks source link

Initial Date Does Does not visually set the text of the form field #24

Closed 5Gears0Chill closed 2 years ago

5Gears0Chill commented 2 years ago

Good day, when setting the initial date, i am stuck with the date being set internally but not showing up on the UI

                  DateTimeFormField(
                          initialDate: _initialDate,
                          decoration: const InputDecoration(
                            hintStyle: TextStyle(color: Colors.black45),
                            errorStyle: TextStyle(color: Colors.redAccent),
                            border: OutlineInputBorder(),
                            suffixIcon: Icon(Icons.event_note),
                            labelText: 'Date Of Birth',
                          ),
                          mode: DateTimeFieldPickerMode.date,
                          autovalidateMode: AutovalidateMode.always,
                          firstDate: DateTime(DateTime.now().year - 120),
                          lastDate: DateTime.now(),
                          validator: (e) => (e) == DateTime.now()
                              ? 'Choose a valid Birthday'
                              : null,
                          onDateSelected: (DateTime value) {
                            _selectedDate = value;
                          },
                        )
GaspardMerten commented 2 years ago

Hello,

The initial date value is only used by the calendar dialogue when there is no value selected.

You probably want to use the initial value parameter instead!