flutter-form-builder-ecosystem / flutter_form_builder

Simple form maker for Flutter Framework
https://pub.dev/packages/flutter_form_builder
MIT License
1.49k stars 541 forks source link

FormBuilderDateTimePicker: Picker always showing when field is required and empty #1304

Open SherpaMiguel opened 1 year ago

SherpaMiguel commented 1 year ago

Is there an existing issue for this?

Package/Plugin version

9.1.1

Platforms

Flutter doctor

Flutter doctor ```bash [✓] Flutter (Channel stable, 3.13.7, on macOS 14.0 23A344 darwin-arm64, locale es-ES) • Flutter version 3.13.7 on channel stable at /Users/miguel/bin/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 2f708eb839 (4 days ago), 2023-10-09 09:58:08 -0500 • Engine revision a794cf2681 • Dart version 3.1.3 • DevTools version 2.25.0 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /Users/miguel/Library/Android/sdk • Platform android-33, build-tools 33.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.0) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A240d • CocoaPods version 1.13.0 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2022.3) • Android Studio at /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.6+0-17.0.6b829.9-10027231) [✓] VS Code (version 1.83.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.56.0 [✓] Connected device (3 available) • iPhone de Miguel Angel (mobile) • 00008110-000414892152401E • ios • iOS 17.0.3 21A360 • macOS (desktop) • macos • darwin-arm64 • macOS 14.0 23A344 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 117.0.5938.149 ! Error: Browsing on the local area network for iPad de Miguel Angel Alvarez Rivero. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac. The device must be opted into Developer Mode to connect wirelessly. (code -27) [✓] Network resources • All expected network resources are available. • No issues found! ```

Minimal code example

Code ```dart FormBuilderDateTimePicker( validator: FormBuilderValidators.required(), autovalidateMode: AutovalidateMode.onUserInteraction, name: 'test', inputType: InputType.time, ); ```

Current Behavior

When validation is fired and field is empty and required, picker is randomly opened.

Expected Behavior

Picker dialog should not open when validation is fired and field is invalid.

Steps To Reproduce

  1. Tap on field to display picker dialog
  2. Press cancel to close dialog without setting a value
  3. Dialog never hides

Aditional information

No response

pixnbit commented 1 year ago

Can confirm.

mokamhawy commented 12 months ago

For me Resolved by setting focusOnInvalid: false, the default is focusOnInvalid: true yourExpiryDateFieldKey.currentState!.validate(focusOnInvalid: false)

pixnbit commented 12 months ago

For me Resolved by setting focusOnInvalid: false, the default is focusOnInvalid: true yourExpiryDateFieldKey.currentState!.validate(focusOnInvalid: false)

This doesn't work if the field is inside a form and is validated with the generic form key. The previous version didn't need this setting.

CGrandez commented 11 months ago

I also have the same problem, any solution?

brandon-watkins-avcrm commented 2 months ago

For me Resolved by setting focusOnInvalid: false, the default is focusOnInvalid: true yourExpiryDateFieldKey.currentState!.validate(focusOnInvalid: false)

This worked for me :)