-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Originally mentioned in #55535 by @whoch in this comment.
The issue might be related to incorrect date separators for particular locales: #63372
This issue occurs because the dateHelpText, dateSeparator in MaterialLocalization are different from the compactDateFormat used by the validator in TextFormField.
In Korea, helpText and separator of MaterialLocalizationKo are as follows:
String get dateHelpText => 'yyyy/mm/dd';
String get dateSeparator => '/';
And compactDateFormat is y. M. d.
InputText is initially shown in y. M. d. format, but when the value is modified, it is changed to y//M//d// by inputFormatters. And Only '/' is entered, therefore cannot be entered y. M. d. format.
HintText also outputs 'yyyy/mm/dd' which is different from the compactDateFormat.
Even if input the hintText format, the errorText is displayed because the _validateDate method, validator of InputDatePickerFormField, internally parse the compateDate.
String _validateDate(String text) {
final DateTime date = _parseDate(text);
if (date == null) {
return widget.errorFormatText ?? MaterialLocalizations.of(context).invalidDateFormatLabel;
} else if (!_isValidAcceptableDate(date)) {
return widget.errorInvalidText ?? MaterialLocalizations.of(context).dateOutOfRangeLabel;
}
return null;
}
DateTime _parseDate(String text) {
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
return localizations.parseCompactDate(text);
}
Can I modify compactDateFormat or can someone solve this issue?