@@ -235,13 +235,22 @@ class _FormBuilderDateTimePickerState extends State<FormBuilderDateTimePicker> {
235
235
FocusNode _focusNode;
236
236
TextEditingController _textFieldController;
237
237
DateTime stateCurrentValue;
238
- DateFormat _dateFormat;
239
238
240
- final _dateTimeFormats = {
241
- InputType .both: DateFormat ("EEEE, MMMM d, yyyy 'at' h:mma" ),
242
- InputType .date: DateFormat ('yyyy-MM-dd' ),
243
- InputType .time: DateFormat ('HH:mm' ),
244
- };
239
+ DateFormat get dateFormat =>
240
+ widget.format ?? _dateTimeFormats[widget.inputType];
241
+ Map _dateTimeFormats;
242
+
243
+ /*@override
244
+ void didChangeDependencies() {
245
+ var myLocale = widget.locale ?? Localizations.localeOf(context);
246
+ print(myLocale);
247
+ _dateTimeFormats = {
248
+ InputType.both: DateFormat.yMMMd(myLocale.toString()).add_Hms(),
249
+ InputType.date: DateFormat.yMd(myLocale.toString()),
250
+ InputType.time: DateFormat.Hm(myLocale.toString()),
251
+ };
252
+ super.didChangeDependencies();
253
+ }*/
245
254
246
255
@override
247
256
void initState () {
@@ -255,9 +264,14 @@ class _FormBuilderDateTimePickerState extends State<FormBuilderDateTimePicker> {
255
264
stateCurrentValue = _initialValue;
256
265
_focusNode = widget.focusNode ?? FocusNode ();
257
266
_textFieldController = widget.controller ?? TextEditingController ();
258
- _dateFormat = widget.format ?? _dateTimeFormats[widget.inputType];
267
+ // var appLocale = Localizations.localeOf(context);
268
+ _dateTimeFormats = {
269
+ InputType .both: DateFormat .yMd (widget.locale? .toString ()).add_Hms (),
270
+ InputType .date: DateFormat .yMd (widget.locale? .toString ()),
271
+ InputType .time: DateFormat .Hm (widget.locale? .toString ()),
272
+ };
259
273
_textFieldController.text =
260
- _initialValue == null ? '' : _dateFormat .format (_initialValue);
274
+ _initialValue == null ? '' : dateFormat .format (_initialValue);
261
275
_focusNode.addListener (_handleFocus);
262
276
}
263
277
@@ -291,7 +305,7 @@ class _FormBuilderDateTimePickerState extends State<FormBuilderDateTimePicker> {
291
305
child: DateTimeField (
292
306
key: _fieldKey,
293
307
initialValue: _initialValue,
294
- format: _dateFormat ,
308
+ format: dateFormat ,
295
309
onSaved: (val) {
296
310
var value = _fieldKey.currentState.value;
297
311
var transformed;
0 commit comments