chore: add loose restrictions to date time text field (#7024)

* chore: add loose restrictions to date time text field

* chore: remove date formatter
This commit is contained in:
Mathias Mogensen 2025-01-05 14:02:29 +01:00 committed by GitHub
parent 7bc358d7ac
commit ed646ccba2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -301,6 +301,14 @@ class _DateTimeTextFieldState extends State<DateTimeTextField> {
focusNode: timeFocusNode,
controller: timeTextController,
style: Theme.of(context).textTheme.bodyMedium,
maxLength: widget.timeFormat == TimeFormatPB.TwelveHour
? 8 // 12:34 PM = 8 characters
: 5, // 12:34 = 5 characters
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp('[0-9:AaPpMm]'),
),
],
decoration: getInputDecoration(
const EdgeInsetsDirectional.fromSTEB(6, 6, 12, 6),
timeFormat.format(hintDate),
@ -359,6 +367,7 @@ class _DateTimeTextFieldState extends State<DateTimeTextField> {
isCollapsed: true,
isDense: true,
hintText: widget.showHint ? hintText : null,
counterText: "",
hintStyle: Theme.of(context)
.textTheme
.bodyMedium