flutter_chips_input
flutter_chips_input copied to clipboard
How to add chip on setState method?
I have added an initial list to InputChip widget, want to add chip on setState method. My list gets updated but chip not displayed on UI. Please help. I'm using 1.6.0 version.
I faced the same problem. I believe the idiomatic solution would be a controller, similar to the TextEditingController that can be used for TextFields, but that requires the maintainer to change the package.
Luckily the same thing can be achieved using a GlobalKey<ChipsInputState<T>> for a ChipsInput<T>. Roughly like this
class MyWidget extends StatelessWidget {
final _chipsKey = GlobalKey<ChipsInputState<int>>();
@override
Widget build(BuildContext context) {
return ChipsInput(
key: _chipsKey,
);
}
void addChip(int chip) {
_chipsKey.currentState.selectSuggestion(chip);
}
}
Thanks @Isodome for your response. That should work.
The plan is to add a ChipsInputController in the next major version
I'm having the same issue. While using selectSuggestion works, it still a workaround. Any idea on when you will release your next major release ?
I'm having the same issue. While using selectSuggestion works, it still a workaround. Any idea on when you will release your next major release ?
Hi @Nico04, I appreciate your patience. However, my schedule is a bit tight (I'm currently working on this and other opensource projects on weekends) and thus it may not be possible to give a date at this moment.
I'll, however, give this the highest priority as this project has been neglected for a bit :-(