flutter_smart_select
flutter_smart_select copied to clipboard
Select/de-select programatically
I'm unable to find any feature that lets me select/deselect items programatically. Use case would be , a user selects an item from one page and navigates to another where he can edit his selection. I would like the previously selected option to be marked as selected on the edit page.
I've tried setting the selected value to true but it's not doing anything. My code is as below
choiceOptions.add( S2Choice<String>( value: choiceOptions.length.toString(), title: _service.name, selected: true, ), );
Me to... I'm even setting the current item that I'm observing on my screen... And nothing seems to work, I don't know what to do now
I need to clear all the selected choices on a button tap. Changing value to []
doesn't clear the selected chips.
SmartSelect<String>.multiple(
...,
value: filter.reasons, // where filter.values is [] after taping a clear button.
...,
)
I have the same problem, does anyone know the solution?
Is there anyone with the solution to this problem?
Here is my solution to react on value changes programmatically :
SmartSelect<String>.single(
// ...
value : < here the value you change programmatically elsewhere >
)
I have added the following method to the file widget.dart in the class S2SingleState<T>
@override
void didUpdateWidget(SmartSelect<T> oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.singleValue != oldWidget.singleValue) {
setState(() => value = widget.singleValue);
// I don't think it is needed here but if you need it, uncomment the following line to return state to onChange callback
// onChange?.call(this);
}
}
The same modifications must be done on SmartSelect<T>.multiple if it is your case.
same issue here
I released https://pub.dev/packages/flutter_awesome_select with fixed null safety. Could you check that everything works for you?
Hi everyone,
I'm really sorry for not maintaining the smart_select package in a long time. It's been a great project, but it's become too difficult for me to maintain, especially since I've been going through a tough time for the past few years.
In its place, I've released a new package called choice. The combination to smart_select and chips_choice with cleaner, more flexible, and composable API for creating inline or prompted choice widgets with single or multiple selection.
I hope you'll check out choice. I think you'll find it to be a great replacement for smart_select.
Thanks for your understanding.