[bug]: Generated form with only drop down form fields has missing methods and multiple errors
Opened this issue · 1 comments
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
- 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'),
];
}
- run stacked generate
- 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
Additional Context
No response
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.