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

Problem on FormBuilderCheckboxList onChanged #70

Closed
shariful2011 opened this issue May 25, 2019 · 1 comment
Closed

Problem on FormBuilderCheckboxList onChanged #70

shariful2011 opened this issue May 25, 2019 · 1 comment

Comments

@shariful2011
Copy link

This is my code for FormBuilderCheckboxlist:
return FormBuilderCheckboxList(
attribute: attribute,
options: options,
//initialValue: null,
decoration: InputDecoration(
labelText: _labelText(),
labelStyle: TextStyle(
color: Color(0xFF4574EC),
),
border: InputBorder.none,
),
leadingInput: true,
validators: mandatory
? [
FormBuilderValidators.required(
errorText: 'Please select $title',
)
]
: [],
onChanged: onChanged,
);

my calling:
MyCheckbox(
attribute: 'treatment',
mandatory: false,
title: 'Treatment received',
options: ['IV Fluids', 'Antibiotics', 'ORS']
.map(
(treatment) => FormBuilderFieldOption(value: treatment),
)
.toList(growable: false),
onChanged: (dynamic val) {
print('treatmentreceived=$val');
setState(() {
_treatment = val;
});
},
)
my UI http://prntscr.com/ntasjk

Whenever I tried to tap on the checkbox I got following exception:
I/flutter ( 6016): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter ( 6016): The following UnsupportedError was thrown while handling a gesture:
I/flutter ( 6016): Unsupported operation: Cannot add to an unmodifiable list
I/flutter ( 6016):
I/flutter ( 6016): When the exception was thrown, this was the stack:
I/flutter ( 6016): #0 UnmodifiableListBase.add (dart:_internal/list.dart:114:5)
I/flutter ( 6016): #1 _FormBuilderCheckboxListState._checkbox.
Please help.

@shariful2011
Copy link
Author

Sorry, it was my mistake. Instead of List, I set String which causes the problem.

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

No branches or pull requests

1 participant