Skip to content

Commit b73e503

Browse files
authored
(feat): Add readOnly parameter tuse to disable onTap
1 parent 84dbb3f commit b73e503

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/src/fields/form_builder_date_time_picker.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ class FormBuilderDateTimePicker extends FormBuilderFieldDecoration<DateTime> {
123123
final EntryModeChangeCallback? onEntryModeChanged;
124124
final bool barrierDismissible;
125125

126+
final bool readOnly;
127+
126128
/// Creates field for `Date`, `Time` and `DateTime` input
127129
FormBuilderDateTimePicker({
128130
super.key,
@@ -191,6 +193,7 @@ class FormBuilderDateTimePicker extends FormBuilderFieldDecoration<DateTime> {
191193
this.selectableDayPredicate,
192194
this.anchorPoint,
193195
this.onEntryModeChanged,
196+
this.readOnly = false,
194197
this.barrierDismissible = true,
195198
}) : super(
196199
builder: (FormFieldState<DateTime?> field) {
@@ -199,7 +202,7 @@ class FormBuilderDateTimePicker extends FormBuilderFieldDecoration<DateTime> {
199202
return FocusTraversalGroup(
200203
policy: ReadingOrderTraversalPolicy(),
201204
child: TextField(
202-
onTap: () => state.showPicker(),
205+
onTap: readOnly ? () {} : () => state.showPicker(),
203206
textDirection: textDirection,
204207
textAlign: textAlign,
205208
textAlignVertical: textAlignVertical,

0 commit comments

Comments
 (0)