kfiross / flutter_holo_date_picker

A Flutter package of datepicker like Holo Theme in Android
MIT License
61 stars 77 forks source link

Use locale for selecting language #6

Closed tverra closed 4 years ago

tverra commented 4 years ago

When handling dates in Flutter, I'm used to using the buildt-in Localizations.localeOf(context).languageCode to get the correct format on dates and so on. An example of formatting dates: DateFormat.yMMMMd(Localizations.localeOf(context).languageCode).format(value). The date is then formatted to to match the language of the device. I'd like to be able to do the same with this package, but it doesn't accept a language code string. Instead I'd have to do something like this;

DateTimePickerLocale dateTimePickerLocale;

switch (locale.languageCode) {
  case 'nb':
    dateTimePickerLocale = DateTimePickerLocale.no_nb;
    break;
  case ...

  default:
    dateTimePickerLocale = DateTimePickerLocale.en_us;
    break;
}

This is not a great solution, since it would have to be updated every time a language is added. It would be a much more flexible solution to let the showSimpleDatePicker method accept a language code string instead.

kfiross commented 4 years ago

Hi, Thanks for the good suggestion, It will be added soon.

kfiross commented 4 years ago

Added It now, issue closed.