diff --git a/lib/src/field.dart b/lib/src/field.dart index 681630c..9e5c144 100644 --- a/lib/src/field.dart +++ b/lib/src/field.dart @@ -132,14 +132,8 @@ class DateTimeField extends StatelessWidget { ]; if (modesWithDate.contains(mode)) { - final DateTime? _selectedDate = await showDatePicker( - context: context, - initialDatePickerMode: initialDatePickerMode!, - initialDate: initialDateTime, - initialEntryMode: initialEntryMode, - firstDate: firstDate, - lastDate: lastDate, - ); + final DateTime? _selectedDate = + await showMaterialDatePicker(context, initialDateTime); if (_selectedDate != null) { _selectedDateTime = _selectedDate; @@ -155,10 +149,8 @@ class DateTimeField extends StatelessWidget { ]; if (modesWithTime.contains(mode)) { - final TimeOfDay? _selectedTime = await showTimePicker( - initialTime: TimeOfDay.fromDateTime(initialDateTime), - context: context, - ); + final TimeOfDay? _selectedTime = + await showMaterialTimePicker(context, initialDateTime); if (_selectedTime != null) { _selectedDateTime = DateTime( @@ -175,6 +167,34 @@ class DateTimeField extends StatelessWidget { } } + /// Launches the Material time picker by invoking [showTimePicker]. + /// Can be @[override]n to allow further customization of the picker options + Future showMaterialTimePicker( + BuildContext context, + DateTime initialDateTime, + ) async { + return showTimePicker( + initialTime: TimeOfDay.fromDateTime(initialDateTime), + context: context, + ); + } + + /// Launches the Material time picker by invoking [showDatePicker]. + /// Can be @[override]n to allow further customization of the picker options + Future showMaterialDatePicker( + BuildContext context, + DateTime initialDateTime, + ) { + return showDatePicker( + context: context, + initialDatePickerMode: initialDatePickerMode!, + initialDate: initialDateTime, + initialEntryMode: initialEntryMode, + firstDate: firstDate, + lastDate: lastDate, + ); + } + @override Widget build(BuildContext context) { String? text;