flutter-form-builder-ecosystem / flutter-form-builder-ecosystem/flutter_form_builder

[FormBuilderDateTimePicker]: FormBuilderDateTimePicker not allow me to use 12Hour Format

Open
#1,391 0 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Dart
Stars
1.6k
Forks
561
PR merge metrics
No merged PRs in 30d

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Package/Plugin version

9.1.0

### Platforms

- [ ] Android
- [ ] iOS
- [ ] Linux
- [ ] MacOS
- [X] Web
- [ ] Windows

### Flutter doctor

```
[✓] Flutter (Channel stable, 3.16.9, on Zorin OS 17.1 6.5.0-28-generic, locale
pt_PT.UTF-8)
• Flutter version 3.16.9 on channel stable at
/home/luis/.flutter-path/3.16.9
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 41456452f2 (4 months ago), 2024-01-25 10:06:23 -0800
• Engine revision f40e976bed
• Dart version 3.2.6
• DevTools version 2.28.5

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /home/luis/Android/Sdk
• Platform android-34, build-tools 34.0.0
• Java binary at:
/home/luis/.local/share/JetBrains/Toolbox/apps/android-studio/jbr/bin/java
• Java version OpenJDK Runtime Environment (build
17.0.10+0-17.0.10b1087.21-11572160)
! Some Android licenses not accepted. To resolve this, run: flutter doctor
--android-licenses

[✓] Chrome - develop for the web
• Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
• Ubuntu clang version 14.0.0-1ubuntu1.1
• cmake version 3.22.1
• ninja version 1.10.1
• pkg-config version 0.29.2

[✓] Android Studio (version 2023.3)
• Android Studio at
/home/luis/.local/share/JetBrains/Toolbox/apps/android-studio
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build
17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.89.0)
• VS Code at /usr/share/code
• Flutter extension version 3.88.0

[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Zorin OS 17.1 6.5.0-28-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.155

[✓] Network resources
• All expected network resources are available.
```

### Minimal code example

```dart
const SizedBox(width: 8.0),
Flexible(
child: FormBuilderDateTimePicker(
inputType: InputType.time,
style: Theme.of(context).textTheme.bodySmall,
name: 'pt_PT',
decoration: textFormFieldDecoration(
context, 'Test pt_PT'),
initialDate: DateTime.now(),
initialTime: TimeOfDay.now(),
),
),

const SizedBox(width: 8.0),
Flexible(
child: FormBuilderDateTimePicker(
format: DateFormat('HH:mm'),
inputType: InputType.time,
style: Theme.of(context).textTheme.bodySmall,
name: 'en_UK',
decoration: textFormFieldDecoration(
context, 'Test en_UK'),
initialDate: DateTime.now(),
initialTime: TimeOfDay.now(),
onChanged: (value) {},
locale: Locale('en', 'UK'),
),
),
```

### Current Behavior

When switching to input text mode to enter time manually, it won't let me put a time above 12hrs.

Furthermore, there is no AM/PM selector in certain locations, such as in my case Locale('pt', 'PT'), but if I change the Locale of FormBuilderDateTimePicker to Locale('en', 'UK') An option will appear to choose AM/PM

### Expected Behavior

I want to use AM/PM selector outside Locale('en', 'UK')

### Steps To Reproduce

Testing Code:

```dart
const SizedBox(width: 8.0),
Flexible(
child: FormBuilderDateTimePicker(
inputType: InputType.time,
style: Theme.of(context).textTheme.bodySmall,
name: 'pt_PT',
decoration: textFormFieldDecoration(
context, 'Test pt_PT'),
initialDate: DateTime.now(),
initialTime: TimeOfDay.now(),
),
),

const SizedBox(width: 8.0),
Flexible(
child: FormBuilderDateTimePicker(
format: DateFormat('HH:mm'),
inputType: InputType.time,
style: Theme.of(context).textTheme.bodySmall,
name: 'en_UK',
decoration: textFormFieldDecoration(
context, 'Test en_UK'),
initialDate: DateTime.now(),
initialTime: TimeOfDay.now(),
onChanged: (value) {},
locale: Locale('en', 'UK'),
),
),
```
Using my default Location as pt_PT
![image](https://github.com/flutter-form-builder-ecosystem/flutter_form_builder/assets/72317733/783e3591-42a5-4a1d-9c3a-65025601654a)
Introduza uma hora válida = Enter a valid time

Meanwhile specifying locale as us_UK:
![image](https://github.com/flutter-form-builder-ecosystem/flutter_form_builder/assets/72317733/debd8594-1f6a-4d8c-a3a5-d58a3e38ecf2)
It display's the AM/PM selector, so I can use 12Hrs format and select if it AM/PM

### Aditional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.