Closed abhihasabe closed 4 years ago
Hello @abhihasabe ,
Can you please share with us your definition of the _dropdownMenuItemsCamp
list?
In particular, the toString()
method of the objects in this list must return a String
containing what your want to match (for example "Maharashtra").
I am having the same issues, I am using Single Object, but when I write anything the list doesn't filter at all.
SearchableDropdown.single( items: _businessList.map((bus) { return (DropdownMenuItem( child: Text(bus.name), value: bus)); }).toList(), value: _selectedBusiness, hint: "Select a business", searchHint: "Select a business", onChanged: (value) { setState(() { _selectedBusiness = value; }); }, dialogBox: false, isExpanded: true, menuConstraints: BoxConstraints.tight(Size.fromHeight(350)), ),
Never mind, I added the toString() method to my object and now it works like a charm.
Hello Icuis,
Please check given code , and for more reference i am sharing git link please check,
_dropdownMenuItemsCamp = buildDropdownCampagin(campTypeList);
List<DropdownMenuItem
Git Link: https://github.com/abhihasabe/MultiselectWithSearchFlutter.git
Thanks & Regards,
Abhijeet Hasabe 7263942833
On Sat, Apr 11, 2020 at 3:35 PM lcuis notifications@github.com wrote:
Hello @abhihasabe https://github.com/abhihasabe ,
Can you please share with us your definition of the _dropdownMenuItemsCamp list?
In particular, the toString() method of the objects in this list must return a String containing what your want to match (for example "Maharashtra").
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/icemanbsi/searchable_dropdown/issues/38#issuecomment-612383888, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYMQWEGNKF6CZ5HCKOP2QLRMA6HVANCNFSM4MF2VHZA .
Hello @abhihasabe ,
Thanks for sharing your code.
I'll take the example of the CurrentRoleBelongTo
class.
For the search to work the way you are using it with this class, you would need to define the toString()
function as follows in lib/model/CurrentRoleBelongTo.dart
:
...
class CurrentRoleBelongTo {
...
String toString(){
return(generalName);
}
...
}
You also need to add a toString()
method the other classes for which you want to use the search the same way:
SourceDataList
DataList
TractorDataList
DataListByState
BranchDataList
employeeDataList
Hello lcuis,
Thank you for support, given code working properly.
On Sun, Apr 12, 2020 at 1:51 PM lcuis notifications@github.com wrote:
Hello @abhihasabe https://github.com/abhihasabe ,
Thanks for sharing your code.
I'll take the example of the CurrentRoleBelongTo class. For the search to work the way you are using it with this class, you would need to define the toString() function as follows in lib/model/CurrentRoleBelongTo.dart:
...class CurrentRoleBelongTo { ...String toString(){return(generalName); } ... }
You also need to add a toString() method the other classes for which you want to use the search the same way:
- SourceDataList
- DataList
- TractorDataList
- DataListByState
- BranchDataList
- employeeDataList
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/icemanbsi/searchable_dropdown/issues/38#issuecomment-612580979, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYMQWDDVS2A2TLAAIPV3NLRMF22NANCNFSM4MF2VHZA .
Thanks for the confirmation @abhihasabe ! Closing this issue. Feel free to reopen if needed.
I have using searchable_dropdown lib, every thing working but searching option not working properly.I am sharing code with some screenshots, lease check help me.
Container( padding: EdgeInsets.all(10.0), child: SearchableDropdown.single( items: _dropdownMenuItemsCamp, value: selectCamp, displayClearIcon: false, isCaseSensitiveSearch: true, hint: "Select Compaign Type ", label: Text( "Select Compaign Type ", style: TextStyle(color: Colors.black54), ), searchHint: "Select Compaign Type *", onChanged: (value) { setState(() { selectCamp = value; }); campType = selectCamp.generalID; }, underline: Container( height: 1.0, decoration: BoxDecoration( border: Border( bottom: BorderSide( color: Colors.black38, width: 1.0))), ), searchFn: (String keyword, items) { List ret = List();
if (keyword != null &&
items != null &&
keyword.isNotEmpty) {
keyword.split(" ").forEach((k) {
int i = 0;
items.forEach((item) {
if (k.isNotEmpty &&
(item.value
.toString()
.toLowerCase()
.contains(k.toLowerCase()))) {
ret.add(i);
}
i++;
});
});
}
if (keyword.isEmpty) {
ret = Iterable.generate(items.length).toList();
}
return (ret);
},
isExpanded: true,
),
)