flutter-form-builder-ecosystem / flutter-form-builder-ecosystem/form_builder_validators
[General]: non-required fields became required in v11.0.0
- Dominant language
- Dart
- Stars
- 67
- Forks
- 106
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 1
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Package/Plugin version
11.0.0
### Platforms
- [X] Android
- [X] iOS
- [ ] Linux
- [ ] MacOS
- [ ] Web
- [ ] Windows
### Flutter doctor
Flutter doctor
```bash
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.4 23E214 darwin-arm64, locale en-GB)
• Flutter version 3.22.2 on channel stable at /Users/techouse/fvm/versions/3.22.2
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 761747bfc5 (6 weeks ago), 2024-06-05 22:15:13 +0200
• Engine revision edd8546116
• Dart version 3.4.3
• DevTools version 2.34.3
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/techouse/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/techouse/Library/Android/sdk
• Java binary at: /Users/techouse/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.1)
• Android Studio at /Users/techouse/Applications/Android Studio.app/Contents
• 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.11+0-17.0.11b1207.24-11852314)
[✓] IntelliJ IDEA Community Edition (version 2024.1.4)
• IntelliJ at /Users/techouse/Applications/IntelliJ IDEA Community Edition.app
• Flutter plugin version 80.0.2
• Dart plugin version 241.17890.8
[✓] Connected device (5 available)
• Pixel 6 (mobile) • xxx • android-arm64 • Android 14 (API 34)
• techouse’s iPhone (mobile) • xxx • ios • iOS 17.5.1 21F90
• macOS (desktop) • macos • darwin-arm64 • macOS 14.4 23E214 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.4 23E214 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.127
[✓] Network resources
• All expected network resources are available.
• No issues found!
```
### Minimal code example
Code sample
```dart
FormBuilderTextField(
name: 'middle_name',
initialValue: context.store.middleName,
autocorrect: false,
autofillHints: const [AutofillHints.middleName],
inputFormatters: [
LengthLimitingTextInputFormatter(64),
],
textCapitalization: TextCapitalization.words,
decoration: const InputDecoration(
labelText: 'Middle name(s)',
hintMaxLines: 1,
),
validator: FormBuilderValidators.compose([
FormBuilderValidators.maxLength(64),
]),
textInputAction: TextInputAction.next,
onSubmitted: (_) => debugPrint('onSubmitted'),
);
```
### Current Behavior
With v11 this field became required even though `FormBuilderValidators.required()` was not one of the validators.
### Expected Behavior
Before v11 this field was not required and would allow the user to skip it.
### Steps To Reproduce
1. create non-required field
2. try to submit form with non-required field
3. validator throws error
### Aditional information
With regards to the [breaking changes in v11](https://github.com/flutter-form-builder-ecosystem/form_builder_validators?tab=readme-ov-file#v10-to-v11), I would have thought that non-required fields would have behaved the same.
Does this now mean that `checkNullOrEmpty` effectively replaces `FormBuilderValidators.required()`? If so, could the documentation highlight this change?
Contributor guide
Assessment
This issue has not been assessed yet.