-
-
Notifications
You must be signed in to change notification settings - Fork 541
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
FormBuilderDropdown assertion bug #220
Comments
Hello, List<DropdownMenuItem> items = this.kv.entries
.map((entry) => DropdownMenuItem(
value: entry.key,
child: Text(entry.value)
)).toList();
return FormBuilderDropdown(
attribute: this.id,
decoration: InputDecoration(labelText: this.title),
// initialValue: value,
// initialValue: ,
hint: Text('Select a choice'),
items: items
); I don't know what is the problem. I set a Here is the return FormBuilder(
key: _fbKey,
initialValue: data.map((key, value) {
KindType p = this.ktypes.firstWhere((k) => k.id == key);
switch (p.job) {
case 'student':
return MapEntry(key, value);
case 'teacher':
return MapEntry(key, value);
case 'administrator':
return MapEntry(key, DateTime.tryParse(value));
case 'family':
return MapEntry(key, value);
default:
return null;
}
}),
autovalidate: true,
child: Column(
children: this.ktypes.map((q) => q.build()).toList()
)
); Any clues for me, please? |
Hi @kasangasj / @maelfosso, Note that if you update the list of Therefore if you change the items mid-flight remember to set the value to null. Another alternative is to ignore (though not advisable) because assertion errors don't appear in production. Sorry for the late response, I thought I had addressed this issue since it's actually a duplicate. |
Hi @danvick How to set the value to null, there is not value field like in default dropdownbutton? |
Hi @2shrestha22 Did you find a way to change it to null or default value? |
I stopped using the package. |
probably this might work, @fuzes formkey.currentState.fields['yourdropdownfieldname'].didChange(null); |
With the official flutter dropdown this does not happen, fix it or I will stop using the library |
Hi @miguelflores1993 . This is a open source package about forms. If you can contribute to solve this problem, will be awesome. If not, we do not seen a problem if you use another package for implement your forms. |
I have two FormBuilderDropdowns which depend on each other, one is for categories and the other is for sub categories. When I change category then sub categories are loaded. This works fine as long as there is no selected subcategory but if I select a category, then select one of its sub categories it throws the following exception:
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building FormField-[LabeledGlobalKey<FormFieldState>#3f353](dirty, dependencies: [_FormScope], state: FormFieldState#68c0b):
There should be exactly one item with [DropdownButton]'s value: {id: 3ebc51ba390511eab6a06b0f2e982c39, name: Self Referral, code: 0002, category_id: 3eb329ef390511eab6a029aa47757af9, category_name: User Fee, active: 1, deleted: 0}.
Either zero or 2 or more [DropdownMenuItem]s were detected with the same value
'package:flutter/src/material/dropdown.dart':
Failed assertion: line 805 pos 15: 'items == null || items.isEmpty || value == null ||
items.where((DropdownMenuItem item) {
return item.value == value;
}).length == 1'
Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=BUG.md
The relevant error-causing widget was:
FormBuilderDropdown-[<'visit_subcategory'>] file:///home/kasanga/AndroidStudioProjects/mobile/lib/dialogs/client_dialog.dart:119:19
When the exception was thrown, this was the stack:
#2 new DropdownButton (package:flutter/src/material/dropdown.dart:805:15)
#3 _FormBuilderDropdownState.build. (package:flutter_form_builder/src/fields/form_builder_dropdown.dart:118:26)
#4 FormFieldState.build (package:flutter/src/widgets/form.dart)
#5 StatefulElement.build (package:flutter/src/widgets/framework.dart:4334:27)
#6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4223:15)
...
═════════════════════
How can I clear the subcategories drop down's value when the categories drop down value changes?
The text was updated successfully, but these errors were encountered: