dropdown_button2
dropdown_button2 copied to clipboard
Searching item.child not working on release mode but in debug mode run successfully.
I've try so many times to fix this case searching item.child didn't work in release mode. because in item child it read as widget text then I add toString().toLowerCase() function. Please help solve this case, here is my code that I'm focused on
searchMatchFn: (item, searchPasien) { return item.child.toString().toLowerCase().contains(searchPasien.toLowerCase()); },
I've try so many times to fix this case searching item.child didn't work in release mode. because in item child it read as widget text then I add toString().toLowerCase() function. Please help solve this case, here is my code that I'm focused on
searchMatchFn: (item, searchPasien) { return item.child.toString().toLowerCase().contains(searchPasien.toLowerCase()); },
Hi, I also get this exact bug, do you have any solution how to fix it? Any help would be appreciated, thanks in advance...
any update on this ?
Can anyone provide a sample that reproduces this issue?
Can anyone provide a sample that reproduces this issue?
please check your email
This issue is because of toString() acts differently on debug/release modes. Might be related to https://github.com/flutter/flutter/issues/148983 or wherever toString is used from.
The unexpected behavior of child.toString() on debug/release modes is unrelated to this package, so I'll close this.
Feel free to share the model child If you need further help.
here is my model toString()
class Speciality extends Equatable {
String? enName;
Speciality({this.enName});
Speciality.fromJson(Map<String, dynamic> json) {
enName = json['enName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['enName'] = this.enName;
return data;
}
@override
List<Object?> get props => [enName];
}
This issue is related to equatable
The stringify value defaults to true in debug mode and false in release mode.
You can fix it by overriding the global [stringify] setting:
EquatableConfig.stringify = true
or, override stringify for a particular class like Speciality:
@override
bool? get stringify => true;
I've opened an issue there that suggests changing this behavior to act the same on debug/release modes.
Furthermore, you might want to rely on props for a better search experience:
return item.props.any(
(prop) => prop.toString().toLowerCase().contains(searchValue.toLowerCase()),
);