salim-lachdhaf / dropdown_search

Simple and robust Dropdown with item search feature, making it possible to use an offline item list or filtering URL for easy customization.
MIT License
346 stars 334 forks source link

Exception on version 6.0.0 #675

Closed virdosdo closed 2 months ago

virdosdo commented 2 months ago

Describe the bug Exception has occurred. _AssertionError ('package:dropdown_search/dropdown_search.dart': Failed assertion: line 188 pos 16: 'T == String || T == int || T == double || compareFn != null': is not true.)

To Reproduce On loading the form with the DropdownSearch widget

Expected behavior The search dropdown display with the elements

Screenshots Attached screen error_dropdown

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context I use a special model, with id and name structure for items. This worked fine before the package update to 6.0.0.

salim-lachdhaf commented 2 months ago

i's not a bug, it's just a way to force users to specify their model DropdownSearch<MyModel> or DropdownSearch<MyModel>.multiSelection if they uses custom models

compareFn is important (required) in case you are used custom model (not primitive type) it defines how compare two object of type your model.

virdosdo commented 2 months ago

Excelent! I solved it with: compareFn: (item1, item2) => item1.id == item2.id Sorry for the inconvenience, I didn't know that the compareFn statement was required. Thank you so much