flutter_form_builder icon indicating copy to clipboard operation
flutter_form_builder copied to clipboard

FormBuilderDateTimePicker: Picker always showing when field is required and empty

Open SherpaMiguel opened this issue 2 years ago • 5 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Package/Plugin version

9.1.1

Platforms

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

Flutter doctor

Flutter doctor
[✓] 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
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

SherpaMiguel avatar Oct 13 '23 15:10 SherpaMiguel

Can confirm.

pixnbit avatar Oct 18 '23 22:10 pixnbit

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

mokamhawy avatar Nov 12 '23 10:11 mokamhawy

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.

pixnbit avatar Nov 12 '23 16:11 pixnbit

I also have the same problem, any solution?

CGrandez avatar Nov 22 '23 15:11 CGrandez