@@ -306,69 +306,70 @@ class FormBuilderCupertinoDateTimePicker extends FormBuilderField<DateTime> {
306306 this .onEntryModeChanged,
307307 this .barrierDismissible = true ,
308308 }) : super (
309- builder: (FormFieldState <DateTime ?> field) {
310- final state = field as _FormBuilderCupertinoDateTimePickerState ;
311-
312- final fieldWidget = FocusTraversalGroup (
313- policy: ReadingOrderTraversalPolicy (),
314- child: CupertinoTextField (
315- onTap: () => state.showPicker (),
316- textDirection: textDirection,
317- textAlign: textAlign,
318- textAlignVertical: textAlignVertical,
319- maxLength: maxLength,
320- autofocus: autofocus,
321- decoration: decoration,
322- readOnly: true ,
323- enabled: state.enabled,
324- autocorrect: autocorrect,
325- controller: state._textFieldController,
326- focusNode: state.effectiveFocusNode,
327- inputFormatters: inputFormatters,
328- keyboardType: keyboardType,
329- maxLines: maxLines,
330- obscureText: obscureText,
331- showCursor: showCursor,
332- minLines: minLines,
333- expands: expands,
334- style: style,
335- onEditingComplete: onEditingComplete,
336- cursorColor: cursorColor,
337- cursorRadius: cursorRadius,
338- cursorWidth: cursorWidth,
339- enableInteractiveSelection: enableInteractiveSelection,
340- keyboardAppearance: keyboardAppearance,
341- scrollPadding: scrollPadding,
342- strutStyle: strutStyle,
343- textCapitalization: textCapitalization,
344- textInputAction: textInputAction,
345- maxLengthEnforcement: maxLengthEnforcement,
346- ),
347- );
348-
349- return CupertinoFormRow (
350- error: state.hasError
351- ? errorBuilder != null
352- ? errorBuilder (state.errorText ?? '' )
353- : Text (state.errorText ?? '' )
354- : null ,
355- helper: helper,
356- padding: contentPadding,
357- prefix: prefix,
358- child: shouldExpandedField
359- ? SizedBox (width: double .infinity, child: fieldWidget)
360- : fieldWidget,
361- );
362- },
363- );
309+ builder: (FormFieldState <DateTime ?> field) {
310+ final state = field as _FormBuilderCupertinoDateTimePickerState ;
311+
312+ final fieldWidget = FocusTraversalGroup (
313+ policy: ReadingOrderTraversalPolicy (),
314+ child: CupertinoTextField (
315+ onTap: () => state.showPicker (),
316+ textDirection: textDirection,
317+ textAlign: textAlign,
318+ textAlignVertical: textAlignVertical,
319+ maxLength: maxLength,
320+ autofocus: autofocus,
321+ decoration: decoration,
322+ readOnly: true ,
323+ enabled: state.enabled,
324+ autocorrect: autocorrect,
325+ controller: state._textFieldController,
326+ focusNode: state.effectiveFocusNode,
327+ inputFormatters: inputFormatters,
328+ keyboardType: keyboardType,
329+ maxLines: maxLines,
330+ obscureText: obscureText,
331+ showCursor: showCursor,
332+ minLines: minLines,
333+ expands: expands,
334+ style: style,
335+ onEditingComplete: onEditingComplete,
336+ cursorColor: cursorColor,
337+ cursorRadius: cursorRadius,
338+ cursorWidth: cursorWidth,
339+ enableInteractiveSelection: enableInteractiveSelection,
340+ keyboardAppearance: keyboardAppearance,
341+ scrollPadding: scrollPadding,
342+ strutStyle: strutStyle,
343+ textCapitalization: textCapitalization,
344+ textInputAction: textInputAction,
345+ maxLengthEnforcement: maxLengthEnforcement,
346+ ),
347+ );
348+
349+ return CupertinoFormRow (
350+ error: state.hasError
351+ ? errorBuilder != null
352+ ? errorBuilder (state.errorText ?? '' )
353+ : Text (state.errorText ?? '' )
354+ : null ,
355+ helper: helper,
356+ padding: contentPadding,
357+ prefix: prefix,
358+ child: shouldExpandedField
359+ ? SizedBox (width: double .infinity, child: fieldWidget)
360+ : fieldWidget,
361+ );
362+ },
363+ );
364364
365365 @override
366366 FormBuilderFieldState <FormBuilderCupertinoDateTimePicker , DateTime >
367- createState () => _FormBuilderCupertinoDateTimePickerState ();
367+ createState () => _FormBuilderCupertinoDateTimePickerState ();
368368}
369369
370- class _FormBuilderCupertinoDateTimePickerState extends FormBuilderFieldState <
371- FormBuilderCupertinoDateTimePicker , DateTime > {
370+ class _FormBuilderCupertinoDateTimePickerState
371+ extends
372+ FormBuilderFieldState <FormBuilderCupertinoDateTimePicker , DateTime > {
372373 late TextEditingController _textFieldController;
373374
374375 late DateFormat _dateFormat;
@@ -380,8 +381,9 @@ class _FormBuilderCupertinoDateTimePickerState extends FormBuilderFieldState<
380381 _dateFormat = widget.format ?? _getDefaultDateTimeFormat ();
381382 //setting this to value instead of initialValue here is OK since we handle initial value in the parent class
382383 final initVal = value;
383- _textFieldController.text =
384- initVal == null ? '' : _dateFormat.format (initVal);
384+ _textFieldController.text = initVal == null
385+ ? ''
386+ : _dateFormat.format (initVal);
385387
386388 effectiveFocusNode.onKeyEvent = (node, event) {
387389 if (event is KeyDownEvent &&
@@ -408,7 +410,7 @@ class _FormBuilderCupertinoDateTimePickerState extends FormBuilderFieldState<
408410 return switch (widget.inputType) {
409411 InputType .time => DateFormat .Hm (languageCode),
410412 InputType .date => DateFormat .yMd (languageCode),
411- InputType .both => DateFormat .yMd (languageCode).add_Hms ()
413+ InputType .both => DateFormat .yMd (languageCode).add_Hms (),
412414 };
413415 }
414416
@@ -488,12 +490,20 @@ class _FormBuilderCupertinoDateTimePickerState extends FormBuilderFieldState<
488490 top: false ,
489491 child: CupertinoDatePicker (
490492 mode: CupertinoDatePickerMode .time,
491- initialDateTime: currentValue ??
492- DateTime (0 , 0 , 0 , widget.initialTime.hour,
493- widget.initialTime.minute),
493+ initialDateTime:
494+ currentValue ??
495+ DateTime (
496+ 0 ,
497+ 0 ,
498+ 0 ,
499+ widget.initialTime.hour,
500+ widget.initialTime.minute,
501+ ),
494502 onDateTimeChanged: (DateTime newDateTime) {
495503 pickedTime = TimeOfDay (
496- hour: newDateTime.hour, minute: newDateTime.minute);
504+ hour: newDateTime.hour,
505+ minute: newDateTime.minute,
506+ );
497507 },
498508 ),
499509 ),
@@ -506,15 +516,21 @@ class _FormBuilderCupertinoDateTimePickerState extends FormBuilderFieldState<
506516
507517 /// Sets the hour and minute of a [DateTime] from a [TimeOfDay] .
508518 DateTime combine (DateTime date, TimeOfDay ? time) => DateTime (
509- date.year, date.month, date.day, time? .hour ?? 0 , time? .minute ?? 0 );
519+ date.year,
520+ date.month,
521+ date.day,
522+ time? .hour ?? 0 ,
523+ time? .minute ?? 0 ,
524+ );
510525
511526 DateTime ? convert (TimeOfDay ? time) =>
512527 time == null ? null : DateTime (1 , 1 , 1 , time.hour, time.minute);
513528
514529 @override
515530 void didChange (DateTime ? value) {
516531 super .didChange (value);
517- _textFieldController.text =
518- (value == null ) ? '' : _dateFormat.format (value);
532+ _textFieldController.text = (value == null )
533+ ? ''
534+ : _dateFormat.format (value);
519535 }
520536}
0 commit comments