@@ -342,7 +342,7 @@ class _FormBuilderDateTimePickerState
342
342
343
343
Future <TimeOfDay ?> _showTimePicker (
344
344
BuildContext context, DateTime ? currentValue) async {
345
- final timePickerResult = await showTimePicker (
345
+ final timePickerResult = await showFormBuilderTimePicker (
346
346
context: context,
347
347
initialTime: currentValue != null
348
348
? TimeOfDay .fromDateTime (currentValue)
@@ -351,6 +351,7 @@ class _FormBuilderDateTimePickerState
351
351
useRootNavigator: widget.useRootNavigator,
352
352
routeSettings: widget.routeSettings,
353
353
initialEntryMode: widget.timePickerInitialEntryMode,
354
+ locale: widget.locale,
354
355
helpText: widget.helpText,
355
356
confirmText: widget.confirmText,
356
357
cancelText: widget.cancelText,
@@ -376,3 +377,56 @@ class _FormBuilderDateTimePickerState
376
377
(value == null ) ? '' : _dateFormat.format (value);
377
378
}
378
379
}
380
+
381
+ Future <TimeOfDay ?> showFormBuilderTimePicker ({
382
+ required BuildContext context,
383
+ required TimeOfDay initialTime,
384
+ TransitionBuilder ? builder,
385
+ bool useRootNavigator = true ,
386
+ TimePickerEntryMode initialEntryMode = TimePickerEntryMode .dial,
387
+ Locale ? locale,
388
+ String ? cancelText,
389
+ String ? confirmText,
390
+ String ? helpText,
391
+ String ? errorInvalidText,
392
+ String ? hourLabelText,
393
+ String ? minuteLabelText,
394
+ RouteSettings ? routeSettings,
395
+ EntryModeChangeCallback ? onEntryModeChanged,
396
+ Offset ? anchorPoint,
397
+ }) async {
398
+ assert (context != null );
399
+ assert (initialTime != null );
400
+ assert (useRootNavigator != null );
401
+ assert (initialEntryMode != null );
402
+ assert (debugCheckHasMaterialLocalizations (context));
403
+
404
+ Widget dialog = TimePickerDialog (
405
+ initialTime: initialTime,
406
+ initialEntryMode: initialEntryMode,
407
+ cancelText: cancelText,
408
+ confirmText: confirmText,
409
+ helpText: helpText,
410
+ errorInvalidText: errorInvalidText,
411
+ hourLabelText: hourLabelText,
412
+ minuteLabelText: minuteLabelText,
413
+ onEntryModeChanged: onEntryModeChanged,
414
+ );
415
+ if (locale != null ) {
416
+ dialog = Localizations .override (
417
+ context: context,
418
+ locale: locale,
419
+ child: dialog,
420
+ );
421
+ }
422
+
423
+ return showDialog <TimeOfDay >(
424
+ context: context,
425
+ useRootNavigator: useRootNavigator,
426
+ builder: (BuildContext context) {
427
+ return builder == null ? dialog : builder (context, dialog);
428
+ },
429
+ routeSettings: routeSettings,
430
+ anchorPoint: anchorPoint,
431
+ );
432
+ }
0 commit comments