Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: Generated form with only drop down form fields has missing methods and multiple errors #1099

Open
dankhan-helmet opened this issue Apr 21, 2024 · 1 comment
Labels

Comments

@dankhan-helmet
Copy link

Describe the bug

When running stacked generate with a form consisting of only dropdown fields, the generated form.dart contains missing methods.

  • The method '_updateFormData' isn't defined for the type $View
  • The method 'validateForm' isn't defined for the type 'FormStateHelper'

If you add these methods back from another generated form with some text fields, the methods are resolved. I think the current code must expect at least one TEXT form field before it adds the _updateFormData and validateForm methods in them.

FYI: My annotation definitions are:

@FormView(
  fields: [
    FormDropdownField(
      name: 'goal1Priority',
      items: AppGoal.all,
    ),
    FormDropdownField(
      name: 'goal2Priority',
      items: AppGoal.all,
    ),
    FormDropdownField(
      name: 'goal3Priority',
      items: AppGoal.all,
    ),
  ],
  autoTextFieldValidation: false,
)

With an AppGoal defined as:

class AppGoal {
  static const List<StaticDropdownItem> all = [
    StaticDropdownItem(title: '1st', value: '1'),
    StaticDropdownItem(title: '2nd', value: '2'),
    StaticDropdownItem(title: '3rd', value: '3'),
  ];
}

What operating system do you use?

macOS

Information about the installed tooling

[✓] Flutter (Channel stable, 3.19.2, on macOS 13.6.4 22G513 darwin-arm64, locale en-NZ)
    • Flutter version 3.19.2 on channel stable at /Users/dan/Library/CloudStorage/Dropbox/Development/Projects/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7482962148 (8 weeks ago), 2024-02-27 16:51:22 -0500
    • Engine revision 04817c99c9
    • Dart version 3.3.0
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/dan/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/dan/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.15.0

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

[✓] Android Studio (version 2023.1)
    • 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.7+0-17.0.7b1000.6-10550314)

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

[✓] Connected device (3 available)
    • iPhone 15 Pro (mobile) • 5708553D-16CB-425E-852B-D3F752379C47 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 13.6.4 22G513 darwin-arm64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 124.0.6367.61

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

• No issues found!

Steps to reproduce the issue

  1. create a new stacked view with the following annotations:
@FormView(
  fields: [
    FormDropdownField(
      name: 'goal1Priority',
      items: AppGoal.all,
    ),
    FormDropdownField(
      name: 'goal2Priority',
      items: AppGoal.all,
    ),
    FormDropdownField(
      name: 'goal3Priority',
      items: AppGoal.all,
    ),
  ],
  autoTextFieldValidation: false,
)

With AppGoal defined as:

class AppGoal {
  static const List<StaticDropdownItem> all = [
    StaticDropdownItem(title: '1st', value: '1'),
    StaticDropdownItem(title: '2nd', value: '2'),
    StaticDropdownItem(title: '3rd', value: '3'),
  ];
}
  1. run stacked generate
  2. note the generated form.dart contains the missing methods and are marked in the IDE with multiple errors.

Expected behavior

No errors in generated file and methods present

Screenshots

CleanShot 2024-04-22 at 09 59 10

CleanShot 2024-04-22 at 09 59 27

CleanShot 2024-04-22 at 09 59 44

Additional Context

No response

@FilledStacks
Copy link
Contributor

Hey @dankhan-helmet, thanks for filing this issue.

We kind of half removed the dropdown form functionality but I think this can be fixed for now by adding a FormTextField in there for now even if you don't use it.

Let me know if that workaround works, will add this to the list of fixes to make.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants