icemanbsi / searchable_dropdown

MIT License
107 stars 166 forks source link

widget.value == null #6

Closed zangen closed 4 years ago

zangen commented 4 years ago

I use your demo,i had this problen, family: Roboto, size: 15.0, weight: 400, baseline: ideographic, decoration: TextDecoration.none, softWrap: wrapping at box width, overflow: clip): 'package:searchable_dropdown/searchable_dropdown.dart': Failed assertion: line 90 pos 12: 'widget.value == null || widget.items.where((DropdownMenuItem item) => item.value == widget.value).length == 1': is not true.

FarhanSaikh commented 4 years ago

@ zangen , I Got same issue. did you able to solve the problem ?

tonytang0114 commented 4 years ago

I have the same problem Found out that the source code here somehow is not true

assert(widget.value == null ||
    widget.items.where((DropdownMenuItem<T> item) => item.value == widget.value).length == 1);
_selectedIndex = null;
for (int itemIndex = 0; itemIndex < widget.items.length; itemIndex++) {
  if (widget.items[itemIndex].value == widget.value) {
    _selectedIndex = itemIndex;
    return;
  }

}

lwcinfo commented 4 years ago

replace this line assert(widget.value == null || widget.items.where((DropdownMenuItem<T> item) => item.value == widget.value).length == 1);

for this

assert(widget.value == null || widget.items.where((DropdownMenuItem<T> item) => item.value == widget.value).length <= 1);

lcuis commented 4 years ago

Hello @zangen @FarhanSaikh @tonytang0114 @lwcinfo ,

Thanks for reporting this issue, finding the root cause and finding a fix.

PR #10 has just been merged. A new parameter has been added defaulted to true to allow the avoidance of the items check part of this assert.

assertUniqueValue: false,

Can you please let us know whether adding the above line to your call solves your issue with the latest version of the plugin?

lcuis commented 4 years ago

Hello @zangen @FarhanSaikh @tonytang0114 @lwcinfo ,

I recently realized that the latest version of the plugin is not available on pub.dev and that if you want to try it, you would have to either wait for the publication or temporarily use the following in your pubspec.yaml file:

  searchable_dropdown:
    git:
      url: https://github.com/icemanbsi/searchable_dropdown.git

Sorry for the inconvenience.

icemanbsi commented 4 years ago

Hi @zangen @FarhanSaikh @tonytang0114 @lwcinfo I've published the update (thanks @lcuis ) on pub.dev. I'll close this issue and feel free to reopen if you think this issue is not solved yet. Thanks