-
Notifications
You must be signed in to change notification settings - Fork 229
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
initialValue not work in MultiSelectChipField #11
Comments
initialValue also not working in MultiSelectDialogField. Thanks. |
Could this be the reason?
Could it be that support for a Comparable object is necessary? |
Getting back to looking at this, a simple solution that doesn't require change the library would be to override the == operator (and, therefore, also hashCode). (I'm new to Dart/Flutter so this was not immediately obvious to me.) |
Thanks @augb for pointing me in the right direction. For anyone that might stumbled upon this, the solution is to override the == operator and hashCode just like augb said. For example: class Person {
final String name;
const Person(this.name);
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Person &&
runtimeType == other.runtimeType &&
name == other.name;
@override
int get hashCode => name.hashCode;
} |
i am also facing same issue, |
Hello, I'm trying to reproduce this issue. Can someone please provide a code example where this is failing? I'm using version 3.1.6 and have tried a couple simple examples. // setting the entire list as initial value
MultiSelectChipField(
items: _items,
initialValue: _animals,
onSaved: (val) {
_selectedAnimals = val;
},
) // setting a couple values from the list
MultiSelectDialogField(
onConfirm: (val) {
_selectedAnimals = val;
},
items: _items,
initialValue: [_animals[0], _animals[2]],
), // setting the _selectedAnimals3 to desired pre-selected values list in initState - recommended
MultiSelectBottomSheetField(
onConfirm: (values) {
_selectedAnimals3 = values;
},
items: _items,
initialValue: _selectedAnimals3,
chipDisplay: MultiSelectChipDisplay(
onTap: (item) {
_selectedAnimals3.remove(item);
return _selectedAnimals3;
},
),
), I've also tried running the example app with no issue. |
3rd Code block cleared my issue (on tap of chipDisplay remove the taped initial value). we need to add the return statement in the onTap function Thanks, @CHB61 |
@madhan-asmb Great! I hope this solutions works for everyone experiencing this problem. Going to drop a link to the first issue regarding this type of problem which provides more background. |
@CHB61 |
Did you find any solution? |
Thank @augb and @taufan-mft . |
No description provided.
The text was updated successfully, but these errors were encountered: