flutter-form-builder-ecosystem / flutter_form_builder

Simple form maker for Flutter Framework

Home Page:https://pub.dev/packages/flutter_form_builder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

focusOnInvalid invalid

iStarEternal opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Package/Plugin version

8.0.0

Platforms

  • Android
  • iOS
  • Linux
  • MacOS
  • Web
  • Windows

Flutter doctor

[✓] Flutter (Channel stable, 3.7.9, on macOS 13.5 22G74 darwin-arm64, locale zh-Hans-CN)
• Flutter version 3.7.9 on channel stable at /Users/star/flutter/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 62bd79521d (8 months ago), 2023-03-30 10:59:36 -0700
• Engine revision ec975089ac
• Dart version 2.19.6
• DevTools version 2.20.1
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /Users/star/Library/Android/sdk
• Platform android-33, build-tools 33.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
• CocoaPods version 1.12.0

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.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 11.0.13+0-b1751.21-8125866)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.1)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 74.0.4
• Dart plugin version 231.8770.15

[✓] VS Code (version 1.84.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.76.0

[✓] Connected device (3 available)
• iPhone 14 (mobile) • D6A01FD8-C25C-4676-B720-A1DEEBD16167 • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.5 22G74 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 119.0.6045.159

[✓] HTTP Host Availability
• All required HTTP hosts are available

• No issues found!

Minimal code example

_formKey.currentState!.validate(focusOnInvalid: false)

Current Behavior

~

Expected Behavior

~

Steps To Reproduce

In FormBuilderState, method validate will call FormBuilderState()._formKey.currentState.validate(). but no argument focusOnInvalid

currentState is FormState.

And in FormState, validate will call FormFieldState.validate(), and no argument focusOnInvalid.

Now, FormBuilderFieldState extends FormFieldState, and override validate, and added agument focusOnInvalid.

so, FormBuilderState does not pass argument focusOnInvalid into FormBuilderFieldState.

Aditional information

No response

We have a solution but so ugly.

FormBuilder(
  key: _formKey,
  onChanged: () {
    buttonEnabled.value =
      _formKey.currentState!.fields.values.fold(true, (previousValue, element) => previousValue && element.validate(focusOnInvalid: false));
  },
  ...
)