admin管理员组文章数量:1123707
I have a DropdownButton2 widget in which searching is there based on 2 parts: a number before a space and some text after the space in the "child" of DropdownMenuItem. The searching is working correctly for 2 parts in debug mode but not working at all in release mode.
I want to search with both the 1st part and the 2nd part i.e. the number and the text. Is there anything I need to add for the release mode?
Please help!
Here is the code:
List<MyParts> myPartList = snapshot.data!;
List<DropdownMenuItem<String>> dropdownPartNumbers =
myPartList.map<DropdownMenuItem<String>>((item) {
String rawmatName = item.rawmatname!.length > 10
? "${item.rawmatname!.substring(0, 10)}..."
: item.rawmatname!;
return DropdownMenuItem<String>(
value: "${item.rawmatcode}-${item.serialNocapture}",
child: Text("${item.rawmatcode!} ($rawmatName)"),
);
}).toList();
// DropdownButton2 widget:
DropdownButtonHideUnderline(
child: DropdownButton2<String>(
isExpanded: true,
hint: Text(
'Select Part',
style: TextStyle(
fontSize: 14,
color: Theme.of(context).hintColor,
),
),
items: dropdownPartNumbers,
value: _selectedValues[index],
onChanged: (value) {
setState(() {
_selectedValues[index] = value!;
if (value.contains("Y")) {
_qtyValues[index] = 1;
_isReadOnlyList[index] = true;
} else {
_isReadOnlyList[index] = false;
}
_isVisibleList[index] = value.contains("Y");
});
},
buttonStyleData: const ButtonStyleData(
padding: EdgeInsets.symmetric(horizontal: 16),
height: 60,
width: 200,
),
dropdownStyleData: const DropdownStyleData(
maxHeight: 350,
),
menuItemStyleData: const MenuItemStyleData(
height: 60,
),
dropdownSearchData: DropdownSearchData(
searchController: searchController,
searchInnerWidgetHeight: 100,
searchInnerWidget: Container(
height: 60,
padding: const EdgeInsets.only(
top: 8,
bottom: 4,
right: 8,
left: 8,
),
child: TextFormField(
expands: true,
maxLines: null,
controller: searchController,
decoration: InputDecoration(
isDense: true,
contentPadding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 8,
),
hintText: 'Search for part...',
hintStyle: const TextStyle(fontSize: 14),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
),
searchMatchFn: (item, searchValue) {
final lowerCaseValue =
searchValue.toLowerCase();
final parts = item.child
.toString()
.toLowerCase()
.split(" ");
final firstPart = parts[0];
final secondPart = parts.length > 1
? parts.sublist(1).join(" ")
: "";
return firstPart.contains(lowerCaseValue) ||
secondPart.contains(lowerCaseValue);
},
),
//This to clear the search value when you close the menu
onMenuStateChange: (isOpen) {
if (!isOpen) {
searchController.clear();
}
},
),
)
本文标签: dropdownSearching in dropdownButton2 in flutter is not working in release modeStack Overflow
版权声明:本文标题:dropdown - Searching in dropdownButton2 in flutter is not working in release mode - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736590805a1945074.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论