-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
ChoiceChip get unselected strangely #13
Comments
Hi evanse9, Much appreciated! Would you mind sharing your code so I can learn from it? |
Hi, we were able to resolve the problem. I uploaded 3 images were you can see the List we created, the original Choice.inline widget code and the modified Choice.inline code. In the original code, we used the prewritten methods provided by the Choice package at the level of the 'selected' and 'onselected' properties which is but in the modified(fixed) version we created a variable (Selected_car_K) which can hold a certain string and compare it's value to the name(text written on the choice chip) of the choice chip, and if the names are the same, the state of that choice chip is changed and it get selected. This is the code |
I see! To manage the selected value in your
Here's a code example that demonstrates both approaches: InlineChoice<String>.single(
clearable: true,
value: selectedValue, // Set initial value
onChanged: (newValue) { // Handle value changes from outside
setState(() {
selectedValue = newValue;
});
},
itemCount: choices.length,
itemBuilder: (state, i) {
return ChoiceChip(
selected: state.selected(choices[i]),
onSelected: state.onSelected(choices[i]),
label: Text(choices[i]),
);
},
), |
Hi davigmacode, thank you for this sweet package😊. I've been utilizing the package you provided recently and noticed an interesting observation. In one of our projects, we incorporated ChoiceChip widgets both with and without the choice package. We found that when a ChoiceChip implemented without the choice package was selected, it inadvertently deselected other ChoiceChips implemented with the choice package. This behavior piqued my curiosity, prompting me to reach out to you for clarification.
The text was updated successfully, but these errors were encountered: