我的自动完成源代码有一些样式和自定义的下拉列表,因为下拉列表超出了屏幕,因为搜索图标添加到搜索栏:
这几乎就像是自动完成下拉框的顶部边框。无论如何要删除这个边框吗?
Container(
height:40.0,
padding: EdgeInsets.only(left:10.0,right:10.0),
child: InputDecorator(
decoration: InputDecoration(
prefixIcon: const Icon(Icons.search, size: 25.0,),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(50.0),
borderSide: const BorderSide(
width: 0,
style: BorderStyle.none,
),
),
filled: true,
hintStyle: TextStyle(color: Colors.grey[800]),
hintText: "Type in your text",
fillColor: Colors.white,
isDense: true,
// contentPadding: EdgeInsets.all(0.0),
),
child: Autocomplete<String>(
optionsBuilder:
(TextEditingValue textEditingValue) {
if (textEditingValue.text == '') {
return const Iterable<String>.empty();
}
return _kOptions.where((String option) {
return option.contains(
textEditingValue.text.toLowerCase());
});
},
optionsViewBuilder: ((context, onSelected, options){
return Align(
alignment: Alignment.topLeft,
child: Material(
elevation: 4.0,
child: ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 200, maxWidth: 300), //RELEVANT CHANGE: added maxWidth
child: ListView.builder(
padding: EdgeInsets.zero,
shrinkWrap: true,
itemCount: options.length,
itemBuilder: (BuildContext context, int index) {
final String option = _kOptions.elementAt(index);
return InkWell(
onTap: () {
onSelected(option);
},
child: Builder(builder: (BuildContext context) {
final bool highlight = AutocompleteHighlightedOption.of(context) == index;
return Container(
color: highlight ? Theme.of(context).focusColor : null,
padding: const EdgeInsets.all(16.0),
child: Text(option),
);
}),
);
},
),
),
),
);
}
),
),
),
),
2条答案
按热度按时间zf2sa74q1#
试试这个
sdnqo3pr2#
你可以试试这个。这将创建一个没有下划线的矩形边框的自动补全。