dropdown_button2 icon indicating copy to clipboard operation
dropdown_button2 copied to clipboard

Searching item.child not working on release mode but in debug mode run successfully.

Open irving-dp opened this issue 1 year ago • 1 comments
trafficstars

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()); },

irving-dp avatar Feb 16 '24 16:02 irving-dp

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...

AqsoLath avatar Apr 29 '24 04:04 AqsoLath

any update on this ?

heshesh2010 avatar Oct 27 '24 17:10 heshesh2010

Can anyone provide a sample that reproduces this issue?

AhmedLSayed9 avatar Oct 27 '24 17:10 AhmedLSayed9

Can anyone provide a sample that reproduces this issue?

please check your email

heshesh2010 avatar Oct 27 '24 17:10 heshesh2010

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.

AhmedLSayed9 avatar Oct 27 '24 18:10 AhmedLSayed9

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];
}

heshesh2010 avatar Oct 27 '24 18:10 heshesh2010

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.

AhmedLSayed9 avatar Oct 27 '24 19:10 AhmedLSayed9

Furthermore, you might want to rely on props for a better search experience:

return item.props.any(
  (prop) => prop.toString().toLowerCase().contains(searchValue.toLowerCase()),
);

AhmedLSayed9 avatar Oct 27 '24 19:10 AhmedLSayed9